Getting daily averages with pandas

I found a way to create the daily average values ​​of many variables, for example, a database that has the following structure:

Fecha,Time, DirViento, MagViento, Temperatura, Humedad, PreciAcu.

Each column presents data every 15 minutes daily. I share the code that, with the help of your comments, adapted to my project. The code calculates the average of the Temperatura and Humedad columns, as well as the sum of the PreciAcu column. The code is as follows:

import numpy as np
import pandas as pd


data = pd.read_csv('tancoyol.csv')
index5=data.set_index(['Fecha','Hora'],inplace=True)

grouped = index5.groupby(level=0)
stat_cea = grouped.agg({'Temperatura':np.mean,'Humedad':np.mean,'PreciAcu':np.sum})
print 'Done............'

Now I have one more question: I need to convert the DirViento column to radians, how can I do this and how to add this new column to my data file?

So, I need to get 3 columns from aggregating a DirViento column into a data file.

DirViento                       
1/07/2011 00:00:00        
1/07/2011 00:15:00        
1/07/2011 00:30:00       
1/07/2011 00:45:00      
2/07/2011 00:00:00           
2/07/2011 00:15:00     
2/07/2011 00:30:00     
2/07/2011 00:45:00         
.                            
.                          
.              

In particular:

DirViento Radians ( Rad) -, Rad ( Sin) -, Rad ( Cos).

?

+1

All Articles