Reputation: 89
i have a dataframe created in pandas which is looks like this:
A B C
X Y Z X Y Z X Y Z
Y K 2 5 12 11 9 8 4 5 12
K 4 4 13 15 5 4 6 7 2
K 6 7 14 0 2 3 0 6 8
C M 4 5 12 5 2 2 1 14 0
M 6 7 2 3 1 6 7 12 5
M 0 6 8 7 3 9 6 8 4
D N 7 1 13 15 9 8 1 13 5
N 9 0 14 0 5 4 0 14 6
N 3 2 12 5 2 3 1 2 2
I want to make it looks like this:
A B C
X Y Z X Y Z X Y Z
Y K 2 5 12 11 9 8 4 5 12
K 4 4 13 15 5 4 6 7 2
K 6 7 14 0 2 3 0 6 8
A B C
X Y Z X Y Z X Y Z
C M 4 5 12 5 2 2 1 14 0
M 6 7 2 3 1 6 7 12 5
M 0 6 8 7 3 9 6 8 4
A B C
X Y Z X Y Z X Y Z
D N 7 1 13 15 9 8 1 13 5
N 9 0 14 0 5 4 0 14 6
N 3 2 12 5 2 3 1 2 2
Is there is any way i can do that? I have tried several ways with concat/merge/join, but i didn't find a way how i can keep column names for "Y,C,D"
Upvotes: 0
Views: 687
Reputation: 249502
No it is not possible using the standard DataFrame string output/display functions. If there were a way to do that it might be a "display option" but those are all listed here and I don't see a relevant one for you: https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#available-options
Upvotes: 1