Try to search your question here, if you can't find : Ask Any Question Now ?

expanding the dataframe by resampling each row to have a range before and after each specific row in pandas

HomeCategory: stackoverflowexpanding the dataframe by resampling each row to have a range before and after each specific row in pandas
Avatargaurav asked 2 weeks ago

Suppose that we have this dataframe:

date                   value    
2017-01-10 9:30:00       0      
2017-02-11 10:00:00      1   

I want to expand each row to become in range of 2 hours before and after that time and being resampled in each 30 minutes and the value should be copied for the newly generated rows.

Here is the results that I want to have:

date                   value    
2017-01-10 7:30:00      0
2017-01-10 8:00:00      0
2017-01-10 8:30:00      0 
2017-01-10 9:00:00      0
2017-01-10 9:30:00      0  
2017-01-10 10:00:00     0 
2017-01-10 10:30:00     0
2017-01-10 11:00:00     0 
2017-01-10 11:30:00     0

2017-02-11 8:00:00      1
2017-02-11 8:30:00      1
2017-02-11 9:00:00      1
2017-02-11 9:30:00      1
2017-02-11 10:00:00     1
2017-02-11 10:30:00     1
2017-02-11 11:00:00     1 
2017-02-11 11:30:00     1
2017-02-11 12:00:00     1
1 Answers
Best Answer
AvatarFernando answered 2 weeks ago
Your Answer

5 + 15 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com