'Dataframe column not showing in one line

I have a dataframe imported from csv file and I have set option of ('display.max_colwidth', None) still the column (column named 'Week') values (which are strings) come in two lines. What should I write so that it comes in one line?

enter image description here

One thing is that if I display less columns then it comes one line (in the above pic I had set the option to display all columns, although they are not visible in the truncated screenshot). This can be seen in below pic.

enter image description here



Solution 1:[1]

pd.set_option sets one single option at the time. If you want to set multiple options you have to call it multiple times.

In your case that would be:

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

Alternatively you can set all these options using a for loop:

options = {'display.max_rows': None, 
           'display.max_columns': None, 
           'display.max_colwidth', None}

for option, value in options.items():
    pd.set_option(option, value)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mozway