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
  • 23,210
  • 7
  • 49
  • 68
OcMaRUS
  • 159
  • 9

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
  • 14,458
  • 5
  • 18
  • 47