Search code examples
pythonpandasdataframespydertruncate

How to not truncate columns when printing dataframes (show all columns)


I tried all these, even though it shows all my columns (11 of them) it is seperated by a backslash. It will get messy when i have alot of rows, thus, I want to show all the columns in one line

pd.set_printoptions(max_rows=200, max_columns=11)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)

Currently the printed dataframe looks like this with the above codes incuded:

Column headers = ['Name', 'Phone', 'Email', 'Address', 'Company']

    Name Phone Email \
   john   1212  xx@gmail.com     
    Address Company \
   townhall  abc

I want the columns to be in a singular line like:

Name   Phone   Email       Address    Company 
       
john   1212  xx@gmail.com   townhall  abc  
   

Do i need to do anything in my spyder settings instead? The codes doesn't seem to work


Solution

  • Looks to me you are missing the width option, try the below

    pd.set_option('display.max_rows', 200)
    pd.set_option('display.max_columns', 500)
    pd.set_option('display.width', 1000)