0

I have dataframe: table_revenue

enter image description here

how can I transpose the dataframe and have grouping by 'stations_id' to see final result as:

enter image description here

where values of cells is the price, aggregated by exact date (column) for specific 'station_id' (row)

wjandrea
  • 28,235
  • 9
  • 60
  • 81
OcMaRUS
  • 329
  • 3
  • 13

1 Answers1

1

It seems you need pivot_table():

output = input.pivot_table(index='station_id',columns='endAt',values='price',aggfunc='sum',fill_value=0)
Celius Stingher
  • 17,835
  • 6
  • 23
  • 53