Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Don't truncate columms output

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading