Closed
Description
The output of df.to_string
is different if the columns is a CategoricalIndex
rather than a normal Index
:
>>> data = [[4, 2], [3, 2], [4, 3]]
>>> cols = ["aaaaaaaaa", "b"]
>>> pd.DataFrame(data, columns=cols)
aaaaaaaaa b
0 4 2
1 3 2
2 4 3
>>> pd.DataFrame(data, columns=pd.CategoricalIndex(cols))
aaaaaaaaa b
0 4 2
1 3 2
2 4 3
We can see that the width of the "b" column depends on the width of the "a" column, if the columns are a CategoricalIndex
.
These two examples should return the same repr.