user3591836
user3591836

Reputation: 993

Pandas time series resample

I have a data frame with a datetime stamp column and a value column

datetime                 value
-------------------------------
2014-02-21 17:16:42        1
2014-02-21 17:46:00        2
2014-02-21 19:06:03        2
2014-02-22 03:16:42        4

and I'd like to replace the datetime column with a different datetime column that has additional values in it, and obtain something like this

datetime                 value
-------------------------------
2014-02-21 17:16:42        1
2014-02-21 17:20:00       
2014-02-21 17:46:00        2
2014-02-21 19:06:03        2
2014-02-22 00:06:42       
2014-02-22 03:16:42        4

(Maybe with NaN or something similar in the empty value positions)

I know this isn't resampling, but I didn't know what to call it. Is there a way to do that? Thanks a lot.

Upvotes: 0

Views: 846

Answers (1)

shx2
shx2

Reputation: 64368

As simple as:

df = df[new_index]

Sweet, eah?

Values in new_index which do not appear in df.index will get a NaN value.

Upvotes: 1

Related Questions