1
import pandas as pd
pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', -1)

data = pd.read_csv(...)
data.columns

Given the code above I am expecting to see a complete list of the 668 columns in this data set. Instead the output is truncated like this:

Index(['VIN_SIGNI_PATTRN_MASK', 'NCI_MAK_ABBR_CD', 'MDL_YR', 'VEH_TYP_CD',
       'VEH_TYP_DESC', 'MAK_NM', 'MDL_DESC', 'TRIM_DESC', 'OPT1_TRIM_DESC',
       'OPT2_TRIM_DESC',
       ...
       'EPA_SMART_WAY_DESC', 'MA_COLL_SYMB', 'MA_COMP_SYMB', 'MA_BASE_SYMB',
       'MA_VSR_SYMB', 'MA_PERFORMANCE_IND', 'MA_ROLL_IND', 'PROACTIVE_IND',
       'MAK_CD', 'MDL_CD'],
      dtype='object', length=668)

Why can't I see all 668 columns ?

JHarnach
  • 3,944
  • 7
  • 43
  • 48

2 Answers2

2

Because you are changing Pandas pretty print, not how Python itself is truncating output.

For example: display.max_rows and display.max_columns sets the maximum number of rows and columns displayed when a frame is pretty-printed. Truncated lines are replaced by an ellipsis. https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#frequently-used-options

Instead of this, just do list(data.columns)

Without list() enter image description here

With list() enter image description here

sdhaus
  • 1,866
  • 13
  • 20
0

Your solution works for me... (can scroll to last column)

import pandas as pd
import numpy as np
print(pd.__version__)
pd.set_option('display.max_columns', None)
df = pd.DataFrame(np.random.rand(10, 668))
df

enter image description here

René
  • 4,594
  • 5
  • 23
  • 52