0

My data frame has two columns: Timestamp (first column) and Power (second column). On each day, it collects power measurements. Number of samples per day is around 200. Like this I have a two year data. I want to find maximum on each day and I want to plot it.

My code is:

one_day_data = df.iloc[:,1].groupby(pd.Grouper(key=df.columns[0],freq='D'))
print(one_day_data.max())

Output is:

KeyError: 'The grouper name DateTime is not found'
Msquare
  • 353
  • 1
  • 7
  • 17
  • 1
    You can achieve the same selecting `max(Power)` grouping by `Timestamp`, after converting `Timestamp` to day. If you provided some rows and the columns of the dataframe an exact solution can be worked out – Jorge Lavín Sep 11 '18 at 07:26
  • 1
    Possible duplicate of [Finding hour of daily max using Pandas in Python](https://stackoverflow.com/questions/37443296/finding-hour-of-daily-max-using-pandas-in-python) – Karan Shishoo Sep 11 '18 at 07:29
  • its not an exact duplicate but the solutions provided give you a method of obtaining the max power per day over multiple years – Karan Shishoo Sep 11 '18 at 07:30
  • @casualcoder pd.TimeGrouper is depreciated. – Msquare Sep 11 '18 at 09:04
  • @Msquare yes it has, it now has been replaced by pd.Grouper() which provides an extended functionality. pd.Grouper() can be used in the same manner as pb.TimeGrouper provided you use appropriate parameters – Karan Shishoo Sep 11 '18 at 09:07
  • Do you mean, I can still use TimeGrouper or Do I have to go pd.Grouper(). I did not get it? – Msquare Sep 11 '18 at 09:08
  • TimeGrouper has been depreciated and should not be used, you now need to use pb.Grouper() instead – Karan Shishoo Sep 12 '18 at 08:14

0 Answers0