Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set max string length in pandas

Tags:

python

pandas

I want my dataframe to auto-truncate strings which are longer than a certain length.

basically:

pd.set_option('auto_truncate_string_exceeding_this_length', 255)

Any ideas? I have hundreds of columns and don't want to iterate over every data point. If this can be achieved during import that would also be fine (e.g. pd.read_csv())

Thanks.

like image 889
bcollins Avatar asked Dec 03 '22 18:12

bcollins


1 Answers

pd.set_option('display.max_colwidth', 255)

like image 69
ilmucio Avatar answered Mar 02 '23 07:03

ilmucio