【问题标题】:How to display the column names vertically in Google colab?如何在 Google colab 中垂直显示列名?
【发布时间】:2021-11-23 14:05:18
【问题描述】:

在 google colab 中,我的 df.columns 用于垂直显示列名,如下所示

Index(['col1',

       'col2',

       'col3'],

dtype='object')

我正在尝试不同的 pandas 设置选项,例如

  • pd.set_option('display.max_row',100),
  • pd.set_option('display.max_columns',100), width 等其他问题。

现在,df.columns 显示如下:

Index(['col1', 'col2', 'col3'], dtype='object')

我尝试删除选项,重置其宽度,但无法修复。 如何返回以垂直显示列?

【问题讨论】:

    标签: python pandas output google-colaboratory settings


    【解决方案1】:
    import pprint 
    columns = df.index
    
    pp = pprint.PrettyPrinter(indent=4, width=1)
    pprint.pprint(columns)
    
    

    【讨论】:

      猜你喜欢
      • 2013-08-08
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多