Don't truncate columns output

Question:

I am setting the options like this

pd.options.display.max_columns = None

When I try to print the DataFrame, I get truncated columns:

<class 'pandas.core.frame.DataFrame'>
Index(['contractSymbol', 'strike', 'currency', 'lastPrice', 'change', 'volume',
       'bid', 'ask', 'contractSize', 'lastTradeDate', 'impliedVolatility',
       'inTheMoney', 'openInterest', 'percentChange'],
      dtype='object')
                                   contractSymbol   strike currency  
symbol expiration optionType                                          
TSLA   2022-12-30 calls       TSLA221230C00050000    50.00      USD   
                  calls       TSLA221230C00065000    65.00      USD  

How do I show all columns in one row?

Asked By: Ivan

||

Answers:

Try:

pd.options.display.max_columns = 500

I don’t think None is an option for display.max_columns

Answered By: dataista

I think you need to set the display size to a larger value. According to the documentation, display.max_columns defines the behavior taken when max_cols is exceeded. I’m not sure if this is referring to the number of columns, or the width of all columns. In either case, setting display.width to a larger value:

pd.options.display.width = 120

would probably fix your issue. The default is 80 characters, which is about what you have there before the value is written to a newline. If your editor is in a terminal window that you can resize, you could also try doing that.

Answered By: Woody1193
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.