mercredi 30 novembre 2016

Python - How to resample columns based based on another csv file

Looking at my example below, I want to resample my data to be hourly. I want to average the 'temperature' data over the hour and sum the 'rainfall data over the hour.

Snippet: F = F.csv

enter image description here

So far, my code that works, says:

F = F.resample('h').agg({'temperature':np.mean,'rainfall': np.sum})

But this code is very inefficient because I have over 100 columns to resample differently.

So if I create another csv, example below: G = G.csv

enter image description here

Does anyone have any suggestions on how to code:

When F.column = G.column, resample F.column based on G.row('resample')

Any help would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire