Using Pandas To Find Daily Averages
Solution 1:
Creating mean values by observations is fairly simple. Notice that this is not a concept that is specific to dates, you basically want to create mean-values using some values as group-identifier. Standard code for this is
df = pd.DataFrame(data)
means = df.groupby('DATE').mean()
If you want to separate your data based on three values 'a1', 'a2', 'a3' of a column called 'A', one way to proceed would be
data1 = df[df['A'] == 'a1']
data2 = df[df['A'] == 'a2']
data3 = df[df['A'] == 'a3']
You can do this onto any dataframe - also the one that I earlier called means
. However, if the calculations that you want to do are the same for the different stations
, it does not make sense to separate the data sets. What I would rather do is keep the dataset together, do all the operations, and do not split before looking at results and/or plotting. That is cleaner, imo.
As for identifying columns as dates, I believe this is a question that has been asked (and answered) quite often here.
Post a Comment for "Using Pandas To Find Daily Averages"