Boris Vladimir Comi <gle...@comunidad.unam.mx> escrito:



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

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

Each column is daily data every 15 minutes. I share the code, which, with the 
help of your comments I have adapted to my project. The code calculates the 
average of the columns Temperatura and Humedad as well as the sum of column 
PreciAcu. 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 to radians the DirViento 
column, how I can do this and how can add this new column to my data file?

In summary,i need to obtain 3 columns from the DirViento column agregate to 
datafile.

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
.
.
.

Specifically:

First I need to convert the values of DirViento column to Radians (This should 
be a new column called Rad) Second I need to get the sine of Rad column (This 
should be a new column called Sin) Third I need to get the cosine of Rad column 
(This should be a new column called Cos).

How I can achieve this?
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to