I have a little problem with rotation in pandas. dataframe (dates, location, data) I'm working on is as follows:
dates location data date1 AX date2 AY date3 AZ date1 B XX date2 B YY
Basically, I'm trying to rotate in place to end up with data:
dates ABC date1 X XX etc... date2 Y YY date3 Z ZZ
Unfortunately, when I rotate, the index equivalent to the source date column does not change, and I get:
dates ABC date1 X NA etc... date2 Y NA date3 Z NA date1 NA XX date2 NA YY
Does anyone know how I can fix this problem to get the dataframe formation I'm looking for?
I now call Pivot the following:
df.pivot(index="dates", columns="location")
because I have # columns of data that I want to collapse (I don't want to list each as an argument). In my opinion, by default, pivot rotates the rest of the columns in the dataframe. Thank.
python pandas pivot-table pivot
tomas Jul 09 2018-12-17T00: 00Z
source share