0

I'm trying to bin 8 days at a time starting from the bottom (earliest date). Will using resample 'B' frequency do this or is there an easier way?

This is what ive tried so far but it's creating starting dates that dont exist in the original data. Does it require timezone information when using 'B' frequency so it starts and ends using the correct dates? These are US dates.

date                     values                            
2020-01-27 00:00:00  67609  
2020-01-26 00:00:00  68136  
2020-01-23 00:00:00  68472  
2020-01-22 00:00:00  68460  
2020-01-21 00:00:00  68452  
2020-01-20 00:00:00  68722  
2020-01-19 00:00:00  68737  
2020-01-16 00:00:00  68981  
2020-01-15 00:00:00  69050  
2020-01-14 00:00:00  69032  
2020-01-13 00:00:00  69004  
2020-01-12 00:00:00  69002  
2020-01-09 00:00:00  68583  
2020-01-08 00:00:00  68662  
2020-01-07 00:00:00  68670  
2020-01-06 00:00:00  69395  
2020-01-05 00:00:00  69418  
2020-01-02 00:00:00  69928  
2020-01-01 00:00:00  70162  
2019-12-30 00:00:00  69948  
2019-12-29 00:00:00  69752  
2019-12-26 00:00:00  69450  
2019-12-25 00:00:00  69226  
2019-12-23 00:00:00  69229  
2019-12-22 00:00:00  68944  
2019-12-19 00:00:00  68860 
import pandas as pd
columns = ['date', 'values')
df = pd.DataFrame(data, columns=columns)
df['date'] = pd.to_datetime(df['date'])
df.set_index('date', inplace=True)
resampled_data = df.resample('B')
  • 1
    please read [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/6619250). – hongsy Jan 28 '20 at 01:08
  • check the docs for resampling [here](https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html) you can use `df.set_index('date').tz_localize('US/Pacific')` to set your `tz` – Umar.H Jan 28 '20 at 01:31

0 Answers0