简体   繁体   中英

python pandas.read_csv library print everything in one column

I have this python script:

dati = pd.read_csv(percorso_file,sep='\ s +', 
                   engine='python', header=0, usecols=[0])
print(dati)

the output is as follows:

220  T;2;Africa;24;Africa centro meridionale;983;Sa...
221  T;5;Oceania;50;Oceania;988;Terre australi e an...
222  T;4;America;42;America centro meridionale;992;...
223  T;4;America;42;America centro meridionale;994;...
224  T;5;Oceania;50;Oceania;997;Wallis e Futuna;Wal...

[225 rows x 1 columns]

It prints me all in one column, when in reality there are 20 of them, how do I get everything printed in multiple columns?

After importing pandas, as an alternative to using the context manager, set such options for displaying entire dataframes:

pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
pd.set_option('display.max_colwidth', -1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM