pandas 在熊猫数据框中显示数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42591589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 03:07:00  来源:igfitidea点击:

Display data in pandas dataframe

pythonpython-3.xpandas

提问by user3848207

This code allows me to display panda dataframe contents in Jupyter notebook.

此代码允许我在 Jupyter 笔记本中显示Pandas数据框内容。

import pandas as pd
# create a simple dataset of people
data = {'Name': ["John", "Anna", "Peter", "Linda"],
'Location' : ["New York", "Paris", "Berlin", "London"],
'Age' : [24, 13, 53, 33]
}
data_pandas = pd.DataFrame(data)
# IPython.display allows "pretty printing" of dataframes
# in the Jupyter notebook
display(data_pandas)

However, I am not using Jupyter notebook. I am using pycharm and Anaconda (python v3.6). How should I display data_pandasif I am not using Jupyter?

但是,我没有使用 Jupyter 笔记本。我正在使用 pycharm 和 Anaconda(python v3.6)。data_pandas如果我不使用 Jupyter,我应该如何显示?

回答by Vikash Singh

put data_pandasin a cell and run that cell. It will display the content in output.

放入data_pandas一个单元格并运行该单元格。它将在输出中显示内容。

enter image description here

在此处输入图片说明

To be able to do the same thing in pycharm you will have to run anaconda notebook from pycharm. Which works like this: https://www.jetbrains.com/help/pycharm/2016.3/using-ipython-jupyter-notebook-with-pycharm.html

为了能够在 pycharm 中做同样的事情,你必须从 pycharm 运行 anaconda notebook。其工作原理如下:https: //www.jetbrains.com/help/pycharm/2016.3/using-ipython-jupyter-notebook-with-pycharm.html

Then it's basically same as running a normal jupyter notebook on a different browser.

然后它与在不同浏览器上运行普通 jupyter notebook 基本相同。

If you are running a normal python program and want an inline output, it's not going to happen. You will have to at least run an Ipython program to do so. Iteractive python.

如果您正在运行一个普通的 python 程序并且想要一个内联输出,那么它不会发生。您至少必须运行一个 Ipython 程序才能这样做。迭代蟒蛇。