python - 运行 df.columns 后显示所有列

标签 python python-3.x pandas python-3.6 label

目前我的 DataFrame 中有 120 列。当我执行

df.columns 

我得到一个截断的列表,其中我只看到 20 列而不是 120 列:

Index(['Reporting_FI', 'Reporting_FI_identification',
   'Reporting_FI_identification_type', 'Reporting_FI_street_address_1',
   'Reporting_FI_street_address_2', 'Reporting_FI_city',
   'Reporting_FI_state', 'Reporting_FI_postal_code',
   'Reporting_FI_country_code', 'Transaction_date',
   ...
   'FI_country_code_3', 'FI_name_4', 'FI_branch_4', 'FI_identification_4',
   'FI_identification_type_4', 'FI_account_number_4', 'FI_city_4',
   'FI_state_4', 'FI_country_code_4', 'Additional_infomation_2'],
  dtype='object', length=120)

如何调整它以显示所有 120 个?

我不是在寻找:

pd.set_option('display.max_columns', 120)

谢谢

最佳答案

一种简单的方法是在打印前转换为list:

res = df.columns.tolist()

print(res)

关于python - 运行 df.columns 后显示所有列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50005341/

相关文章:

python - 返回对 PyO3 中成员字段的引用

python - Memcache 对象在特定日期到期

Python/MySQL : "Truncated incorrect double value..." on a simple text insert

python - 添加新数据时无法从 mysql 数据库中获取 python 中的新数据

python - 如何使用 matplotlib 以虚线获取交替颜色?

python-3.x - 显示多个满足特定条件的数据-PANDAS 中的问题

python - 在python 3.6中从公钥到公共(public)地址生成比特币 key 对

python - 用上面的数据填充空白单元格

python - 如何删除 pandas 数据框中特定的重复行?

python - Pandas 数据帧替换速度慢