Pandas 使用 PyDev 插件的 Eclipse IDE 中的数据框未显示所有输出列

Pandas Dataframe not showing all output columns in Eclipse IDE using PyDev Plugin

当我在 Eclipse IDE(使用 PyDev 插件)中打印一个 Pandas 数据帧时,并不是所有的列都显示在控制台中,即使所有的列都在对象,因为我可以保存到 CSV。

这是输入数据框变量的示例:

   month  avg_high  avg_low  record_high  record_low  avg_precipitation
0    Jan        58       42           74          22               2.95
1    Feb        61       45           78          26               3.02
2    Mar        65       48           84          25               2.34
3    Apr        67       50           92          28               1.02
4    May        71       53           98          35               0.48
5    Jun        75       56          107          41               0.11
6    Jul        77       58          105          44               0.00
7    Aug        77       59          102          43               0.03
8    Sep        77       57          103          40               0.17
9    Oct        73       54           96          34               0.81
10   Nov        64       48           84          30               1.70
11   Dec        58       42           73          21               2.56

对于数据框中输入的数据,当我打印数据框时,控制台显示如下(我们可以看到 avg_low 和 record_high 列显示为 ...)

   month  avg_high        ...          record_low  avg_precipitation
0    Jan        58        ...                  22               2.95
1    Feb        61        ...                  26               3.02
2    Mar        65        ...                  25               2.34
3    Apr        67        ...                  28               1.02
4    May        71        ...                  35               0.48
5    Jun        75        ...                  41               0.11
6    Jul        77        ...                  44               0.00
7    Aug        77        ...                  43               0.03
8    Sep        77        ...                  40               0.17
9    Oct        73        ...                  34               0.81
10   Nov        64        ...                  30               1.70
11   Dec        58        ...                  21               2.56

[12 rows x 6 columns]

如能提供帮助,我们将不胜感激!

它只是 pandas 截断您的输出以使其适合屏幕。要打印所有列,请设置正确的 pandas 选项:

import pandas as pd
pd.set_option("display.max_columns", 100)

我遇到了类似的问题,我能够在 "Command Prompt\Terminal shell" 在 Python 中但不在 Eclipse IDE 中使用 PyDev 和 Pandas。

我发现的解决方法是将其包装在打印函数中 Print()

因此,为了在 Eclipse 中查看 df.head(),我正在使用 Print(df.head()) 作为示例。 我希望这可以帮助那里的人。 KR, M.