Python Forum
Pandas resample problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas resample problem
#1
Thank you for your help.
I have a time series dataframe with hourly data distributed over a 20 years period (N = 175297):

Data A B C D
1/1/1989 0:00 12.0000 12.0000 12.0000 12.0000
...
12/31/2008 5:00 11.9678 11.9712 11.9484 11.9484

I need to compute the mean value for each day, the final series will only have 365 values.

The first value will be the mean value of:
01/01/1989,
01/01/1990,
01/01/1991,
01/01/1992,
...
01/01/2008,

The second value will be the mean value of:
01/02/1989,
01/02/1990,
01/02/1991,
01/02/1992,
...
01/02/2008,

I have tried this:

# Import data 
data = pd.read_excel('Bouca.xlsx', index_col=0, header=1).iloc[:,[0,1,2,3-1]]
data.columns = ['W2R','W2L','Hostetler','Flake']

years = data.index.year

W2R=data['W2R'].resample('D', how='mean')
W2L=data['W2L'].resample('D', how='mean')
Hostetler=data['Hostetler'].resample('D', how='mean')
Flake=data['Flake'].resample('D', how='mean')
With this code I can only convert from hourly data to daily data (N=7308)

Can this be made with resample?

Thank you
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020