Search code examples
pythonpandasinfo

pd.info() with 184 columns


I have a DataFrame with 184 columns and i want to print the df.info() result with the NA count. In the same logic of the print of DataFrame in the question here:

How do I expand the output display to see more columns of a pandas DataFrame?

But, when i try to do it with this code:

pd.set_option('display.max_columns', 184)
pd.set_option('display.max_rows', 300)
pd.set_option('display.width', 1000)

df.info()

I dont have the result expected:

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1690516 entries, 0 to 1690515
Columns: 184 entries, code to carnitine_100g
dtypes: float64(123), int64(2), object(59)
memory usage: 2.3+ GB

someone know how to fix it?

Thanks

In the same logic, you can extand the print of DataFrame. Look at the question here:

How do I expand the output display to see more columns of a pandas DataFrame?


Solution

  • From the docs:

    max_cols, int, optional When to switch from the verbose to the truncated output. If the DataFrame has more than max_cols columns, the truncated output is used. By default, the setting in pandas.options.display.max_info_columns is used.

    So you need to set

    pd.set_option('display.max_info_columns', 128)
    

    Or, since it does not support None, in a more dynamic way (obviously will only work after df is created):

    pd.set_option('display.max_info_columns', len(df.columns))