Monday, 9 September 2013

pandas stack dataframe imported from excel

pandas stack dataframe imported from excel

I have a very large dataaset imported from excel into a pandas dataframe.
I have made a short demo example below. This df is the result from my
import. df
A B C A.1 B.1 C.1 A.2 B.2 C.2
Vehicle
car 4 5 5 NaN NaN NaN NaN NaN NaN
bike NaN NaN NaN 3 4 5 NaN NaN NaN
bus NaN NaN NaN NaN NaN NaN 2 3 4
car 4 4 3 NaN NaN NaN NaN NaN NaN
The column names i relabeled with a suffix in the import in to pandas. But
in my Excel sheet they are the same. (only A,B,C) This df is the result
from my import. What I want as a result from this is:
df:
A B C
Vehicle
car 4 5 5
bike 3 4 5
bus 2 3 4
car 4 4 3
Could someone help me with this?

No comments:

Post a Comment