Reputation: 303
I have timeseries data that looks like this:
ticker close
created_at
2020-06-10 18:30:00+00:00 TSLA 1017.419312
2020-06-10 17:02:00+00:00 TSLA 1014.354980
2020-06-10 17:03:00+00:00 TSLA 1014.922302
2020-06-10 17:04:00+00:00 TSLA 1015.626709
2020-06-10 17:05:00+00:00 TSLA 1016.400024
2020-06-10 17:06:00+00:00 TSLA 1017.223389
2020-06-10 17:07:00+00:00 TSLA 1016.110107
2020-06-10 17:08:00+00:00 TSLA 1016.109985
..........................................
I am trying to resample using 5 minute interval here is my code:
df = pd.read_sql_query("SELECT created_at,ticker,close FROM market_data_history WHERE ticker='TSLA' and CREATED_AT > '2020-06-10 00:01:00+00' AND created_at < '2020-06-11 00:01:00+00'",index_col='created_at',con=engine)
# df = pd.read_csv("market_data_history.csv", usecols = ['created_at','ticker','close','volume'])
print(df)
d=df.resample('5T')
print(d)
However, the output is just showing
DatetimeIndexResampler [freq=<5 * Minutes>, axis=0, closed=left, label=left, convention=start, base=0]
Not sure why it isn't getting applied can someone please assist
Upvotes: 0
Views: 47
Reputation: 12503
resample
can be viewed as a kind of a group-by function. You need to specify how you'd like to aggregate resampled data.
For example:
df.resample("5T").max()
would produce:
ticker close
created_at
2020-06-10 17:00:00+00:00 TSLA 1015.626709
2020-06-10 17:05:00+00:00 TSLA 1017.223389
2020-06-10 17:10:00+00:00 NaN NaN
2020-06-10 17:15:00+00:00 NaN NaN
2020-06-10 17:20:00+00:00 NaN NaN
2020-06-10 17:25:00+00:00 NaN NaN
...
Upvotes: 1