dontreadme
dontreadme

Reputation: 15

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  [email protected]     
    Address Company \
   townhall  abc

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

Name   Phone   Email       Address    Company 
       
john   1212  [email protected]   townhall  abc  
   

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

Upvotes: 0

Views: 2132

Answers (1)

oskros
oskros

Reputation: 3305

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)

Upvotes: 2

Related Questions