pandas 数据框未显示在 Pycharm 中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38956660/
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 01:49:38  来源:igfitidea点击:

Dataframe not showing in Pycharm

pythonpandaspycharm

提问by BartDur

I am using PyCharm 2016.2.1 . When I try to view a Pandas dataframe through the newly added feature 'View as DataFrame' in the debugger, this works as expected for a small (e.g. 4x4) DataFrame.

我正在使用 PyCharm 2016.2.1 。当我尝试通过调试器中新添加的功能“View as DataFrame”查看 Pandas 数据帧时,这对于小(例如 4x4)数据帧按预期工作。

However when I try to view a DataFrame (generated by custom script) of ~10,000 rows x ~50 columns, I get the message: "Nothing to show".

但是,当我尝试查看 ~10,000 行 x ~50 列的 DataFrame(由自定义脚本生成)时,我收到消息:“没有任何显示”。

When I run the same script (that generates the DataFrame) in Spyder, I am able to view it, so I am pretty sure it's not an error in my script.

当我在 Spyder 中运行相同的脚本(生成 DataFrame)时,我能够查看它,所以我很确定这不是我的脚本中的错误。

Does anyone know if there is a maximum size to the DataFrames that can be viewed in PyCharm, and if there is a way to change this?

有谁知道可以在 PyCharm 中查看的 DataFrames 是否有最大大小,以及是否有办法改变它?

EDIT:

编辑:

It seems that the maximum size allowed is 1000 x 15 , as in some cases it gets truncated to this size (when the number of rows is too large, but when there are too many columns pycharm just says 'nothing to show').

似乎允许的最大大小是 1000 x 15 ,因为在某些情况下它会被截断到这个大小(当行数太大时,但当列数太多时,pycharm 只是说“没有显示”)。

Still, I would like to know if there is a way to increase the maximum allowed rows and columns viewable through the DataFrame viewer.

不过,我想知道是否有办法增加可通过 DataFrame 查看器查看的最大允许行和列。

回答by Ahmad

I have faced the same problem with PyCharm 2018.2.2. The reason was having a special character in a column's name as mentioned by Yunzhao .

我遇到了同样的问题PyCharm 2018.2.2。原因是云钊所说的列名中有特殊字符。

If your having a column name like 'R&D' changing it to 'RnD' will fix the problem. It's really strange JetBrains hasn't solved this problem for over 2 years.

如果你有一个像“R&D”这样的列名,把它改成“RnD”会解决这个问题。很奇怪,JetBrains 已经超过 2 年没有解决这个问题了。

回答by Alaa M.

As you said in your edit, there's a limit on the number of columns (on my PC though it's far less than 15). However, you can see the whole thing by typing:

正如您在编辑中所说,列数是有限制的(在我的 PC 上,虽然远小于 15)。但是,您可以通过键入以下内容查看整个内容:

df.values

It will show you the whole dataframe, but without the names of the columns.

它会显示整个数据框,但没有列的名称。



Edit:

编辑:

To show the column names as well:

还要显示列名:

np.vstack([df.columns, df.values])

回答by Yunzhao Xing

I have met the same problems. I figured it was because of the special characters in column names (in my case) In my case, I have "%" in the column name, then it doesn't show the data in View as DataFrame function. After I remove it, everything was correctly shown. Please double check if you also have some special characters in the column names.

我遇到了同样的问题。我认为这是因为列名中的特殊字符(在我的情况下)在我的情况下,我在列名中有“%”,那么它不会在 View 中将数据显示为 DataFrame 函数。我删除它后,一切都正确显示。请仔细检查列名中是否还有一些特殊字符。

回答by Tomasz Bartkowiak

This might be helpful for some people experiencing similar problem:

这可能对一些遇到类似问题的人有所帮助:

As of August 2019 SciViewin PyCharm does struggle with displaying DataFrames that have contain nullable integer type, see issue on JetBrains

截至 2019 年 8 月SciView,PyCharm 确实难以显示DataFrame包含可为空整数类型的s ,请参阅JetBrains 上的问题

回答by michael jie

I use PyCharm 2019.1.1 (Community Edition). And when I used right-click "View as DataFrame". I get the message: "Nothing to show".

我使用 PyCharm 2019.1.1(社区版)。当我使用右键单击“View as DataFrame”时。我收到消息:“没什么可显示的”。

But when I click the object tail button "...View as DataFrame", it worked. enter image description here

但是当我单击对象尾部按钮“...View as DataFrame”时,它起作用了。 在此处输入图片说明

I find out that my problem is my DataFrame Object is an Object's param. Right-click the "View as DataFrame" doesn't transfer the class name, need to user input the class's name and param's name.

我发现我的问题是我的 DataFrame 对象是一个对象的参数。右击“View as DataFrame”不传递类名,需要用户输入类名和参数名。

Hope can help somebody.

希望可以帮助某人。

回答by Filipe Aleixo

In the case that you don't strictly need to use the functionalities given by the DataFrame viewer, you can print the whole DataFrame in the output window, using:

如果您并不严格需要使用 DataFrame 查看器提供的功能,您可以在输出窗口中打印整个 DataFrame,使用:

def print_full(x):
    pd.set_option('display.max_rows', len(x))
    print(x)
    pd.reset_option('display.max_rows')

回答by xingpei Pang

In my situation, the problem is caused by two same cloumn name in my dataframe. Check it by:df.columns.shape[0] == len(set(df.columns))

在我的情况下,问题是由我的数据框中的两个相同的克隆名称引起的。通过以下方式检查:df.columns.shape[0] == len(set(df.columns))

回答by Cappo

For the sake of completeness: I face the same problem, due to the fact that some elements in the index of the dataframe contain a question mark '?'. One should avoid that too, if you still want to use the data viewer. Data viewer still worked, if the index strings contain hashes or less-than/greather-than signs though.

为了完整起见:我面临同样的问题,因为数据帧索引中的某些元素包含问号“?”。如果您仍想使用数据查看器,也应该避免这种情况。如果索引字符串包含散列或小于/大于符号,数据查看器仍然有效。

回答by Nicolo Ceneda

I use PyCharm 2019.1.1 (Community Edition) and I run Python 3.7. When I first click on "View as DataFrame" there seems to be the same issue, but if I wait a few second the content pops up. For me it is a matter of loading.

我使用 PyCharm 2019.1.1(社区版)并运行 Python 3.7。当我第一次点击“View as DataFrame”时,似乎有同样的问题,但如果我等几秒钟,内容就会弹出。对我来说,这是一个加载问题。