0

I have a pandas dataframe in the format below:

Timestamp            Column1    Column2   Column3
2018-01-01 00:00:01    5.7        4.0        2.0
2018-01-01 00:00:02    5.7        4.2        1.8
2018-01-01 00:00:03    4.9        5.1        5.5
2018-01-01 00:00:04    5.8        5.2        1.9

and so on. Essentially have data in second level granularity. I am looking to summarize as follows:

Timestamp            Column1    Column2   Column3
2018-01-01 00:00       5.8        5.2       5.5

Essentially for every minute, I want to calculate the max value. Any value occurring between say

  2018-01-01 00:00:01 and 2018-01-01 00:00:59 

needs to be included in the calculation and summarized as value for timestamp

 2018-01-01 00:00:00

I have tried (assuming df is the name of the dataframe) and pandas loaded as pd

 df=df.groupby(pd.Timestamp.floor(df['Timestamp'], freq='min')).max()

But this does not work. Thoughts? Thanks!

FlyingPickle
  • 1,047
  • 1
  • 9
  • 19
  • 1
    Do `df.set_index('Timestamp').resample('1min').max().reset_index()` – cs95 Jan 11 '19 at 19:10
  • Perfect Thanks! FYI...just got an error TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index' Which is solved by your other post https://stackoverflow.com/questions/48272540/pandas-typeerror-only-valid-with-datetimeindex-timedeltaindex-or-periodindex?rq=1 – FlyingPickle Jan 11 '19 at 20:21

0 Answers0