lundi 13 février 2017

Find daily observation closest to specific time for irregularly spaced data

Vote count: 0

I have a python dataframe like (see table below)

Table

which extends over long time periods (months to years) so with very many observation for each day. What I want to do is that I for each day want to retrieve the time series observation closest to a specific time, say 16:00.

My approach so far have been

eodsearch = pd.DataFrame(df['Date'] + datetime.timedelta(hours=16)) eod = df.iloc[df.index.get_loc(eodsearch['Date'] ,method='nearest')]

which currently gives me an error of "Cannot convert input [Time Date, dtype: datetime64[ns]] of type to Timestamp

Moreover I saw that get_loc also accepted tolerance as an input so if I could set tolerance to say 30 min that would be great as well.

Any advice on why my code fails or how to fix it?

Best

asked 20 secs ago

Let's block ads! (Why?)



Find daily observation closest to specific time for irregularly spaced data

Aucun commentaire:

Enregistrer un commentaire