0

I have a file which has different readings in columns. I am able to find daily mean by using the following code. This is when the month, date, time are separated by space. I am just wondering, how can I do the same if I have date,month, year in first column and then time in second column. How can I calculate weekly, daily and monthly averages? Please note, the data is not equally sampled.

import pandas as pd
import numpy as np
df = pd.read_csv("Data_set.csv", sep='\s*', names=["month", "day", "time", "Temperature"])
group=df.groupby(["month","day"])
daily=group.aggregate({"Temperature":np.mean})
daily.to_csv('daily.csv')

Date        Time        T1      T2      T3
17/12/2013  00:28:38    19      23.1    7.3
17/12/2013  00:58:38    19      22.9    7.3
17/12/2013  01:28:38    18.9    22.8    6.3
17/12/2013  01:58:38    18.9    23.1    6.3
17/12/2013  02:28:38    18.8    23      6.3
.....
.....
24/12/2013  19:58:21    14.7    15.5    7
24/12/2013  20:28:21    14.7    15.5    7
24/12/2013  20:58:21    14.7    15.5    7
24/12/2013  21:28:21    14.7    15.6    6
24/12/2013  21:58:21    14.7    15.5    6
24/12/2013  22:28:21    14.7    15.5    5
24/12/2013  22:58:21    14.7    15.5    4
Muhammad
  • 305
  • 2
  • 6
  • 20
  • Your question is very broad here and typically it should be 1 problem per question, you can combine any number of columns to create a datetime column and then [`resample`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.resample.html#pandas.DataFrame.resample) – EdChum Sep 21 '15 at 15:28
  • Note: posting a link to an image doesn't help as much as simply copying and pasting actual text. If you post text, people can simply select it and use `pd.read_clipboard()` to get the frame themselves. With an image, people would have to spend time typing it in, and since there are always other interesting questions to answer people tend to move along instead of doing that. – DSM Sep 21 '15 at 15:29
  • I have changed into text, thanks for your suggestion.My apologies for this as I am new here. @EdChum: I have deleted my second question. Thanks – Muhammad Sep 21 '15 at 15:40
  • See here for [how to combine date and time](http://stackoverflow.com/questions/17978092/combine-date-and-time-columns-using-python-pandas) then look at resample as suggested – EdChum Sep 21 '15 at 15:42

0 Answers0