python - pandas pivoting a dataframe, duplicate rows -


I have a problem with pivot pins dataframe (date, location, data) I'm working on how I look:

  DATE3 AZ DATE1b XX DATE2B YY dates Date data DATE1 axes DATE2AY   

Actually, I Trying to finish with a dataframe like to pivot on the place:

  dates ABC DATE1 x x x etc ... DATE2 Y YY Unfortunately when I smoke, Index, h The original date is the equivalent of the column, does not change and I am getting:  
  date ABC date 1 x NA etc ... date 2 ya dan date 3 jad na date 1 na xx date 2 NA YY   

Do anyone know how to fix this issue, to get the data format format?

I am currently saying pivot in this way:

  df.pivot (index = "date", column = "location")  < / Pre> 

Because I have a data column that I want to pivot (each do not want to be listed as logic). I believe that the rest of the columns in the dataframe pivot the default smoke. Thank you.

If you have more than one data column, call calling without the value column gives you one Pivot frame as columns with a MultiIndex:

  [3]: df out [3]: column data1 data2 index 0 a -0.6023.98-9, 82,524 x 1 .880, 9 27.88,18,551 y 2b -0.23884 9 0.766 9 86z3b -1.304346.99, 55,031x4c -0.094820 0.746046 y5c -0 .835785 1.123243 in z [4]: ​​df.pivot ('index', 'column') out [4]: ​​index abcabc data1 data2 column x -0.6 23 9 8 -1.3,04,346 NaN-0.9 82524 0.9 55031 NaN y 0.880 9 27 NaN -0.0 9 4820 0.818551 NaN 0.746046 z NaN -0.23884 9 -0.835785 NaN766 9 86 1 .1,23,243    

Comments