0

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?

Ouakrat
  • 67
  • 1
  • 9
  • 1
    *"pd.info() with 184 columns"* is not a question. *"How do I get `pd.info()` to display all columns of a dataframe"* is a question. You could even search on the latter to find existing answers. You'd find the [9-year-old answer with 1085 upvotes](https://stackoverflow.com/a/11711637/202229), admittedly old, but points you in the right direction. – smci Mar 26 '21 at 11:37
  • @smci that is **not** a dupe. The question you linked to refers to printing the df itself using `print(df)` – DeepSpace Mar 26 '21 at 11:50
  • @DeepSpace: I'm aware of that, but answers there do also reference `max_info_columns` and you're free to point out the distinction. Since there's an interplay between whether you do/don't use jupyter, `max_width`, `max_columns`, `max_colwidth` and other options, also pandas changes frequently, also the introduction of context-handlers like `with option_context('display.max_rows', 10, 'display.max_columns', 5):`, it would be totally unreasonable to have a question for each variant; look how fast the answers age. So broadly yes it is a dupe. – smci Mar 26 '21 at 21:41

1 Answers1

1

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))
DeepSpace
  • 78,697
  • 11
  • 109
  • 154
  • Thanks! this what i needed – Ouakrat Mar 26 '21 at 11:38
  • Please post this at the existing question [How do I expand the output display to see more columns of a pandas DataFrame?](https://stackoverflow.com/questions/11707586/how-do-i-expand-the-output-display-to-see-more-columns-of-a-pandas-dataframe) and people can upvote your answer there. This reasking is likely to be closed-as-dupe. – smci Mar 26 '21 at 11:43
  • @smci that is **not** a dupe. The question you linked to refers to printing the df itself using `print(df)` – DeepSpace Mar 26 '21 at 11:46
  • @DeepSpace: I'm aware of that, but answers there do also reference `max_info_columns` and you're free to point out the distinction. Since there's an interplay between whether you do/don't use jupyter, `max_width`, `max_columns`, `max_colwidth` and other options, also pandas changes frequently, also the introduction of context-handlers like `with option_context('display.max_rows', 10, 'display.max_columns', 5):`, it would be totally unreasonable to have a question for each variant; look how fast the answers age. So broadly yes it is a dupe. – smci Mar 26 '21 at 21:39