I have the following dataframe:
Name Number Date Time Temperature RH Height AH
0 Rome 301 01/10/2019 02:00 20.5 89 10 15.830405
1 Rome 301 01/10/2019 05:00 19.4 91 10 15.176020
.. ... ... ... ... ... .. ... ...
91 Napoli 600 02/10/2019 11:00 30.5 52 5 16.213860
92 Napoli 600 02/10/2019 14:00 30.3 51 5 15.731054
Under "Name" there are a few locations, under AH is the Absolute Humidity.
I want to calculate the median AH per each location for each Date (There are 2 days)
and to display each of these daily medians in new columns called med_AH_[Date]
. (In total 2 new columns).
How do I do this?
This is what I have until now:
my_data['med_AH_[Date]']= my_data.groupby('Name')['AH'].transform('median')
But it naturally provides me only the medians by Name and with no division between dates.