0

Is it possible to use .resample() to take the last observation in a month of a weekly time series to create a monthly time series from the weekly time series? I don't want to sum or average anything, just take the last observation of each month Thank you.

Yago
  • 63
  • 5

2 Answers2

0

Based on what you want and what the documentation describes, you could try the following :

data[COLUMN].resample('M', convention='end')

Try it out and update us!

References https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.resample.html

rafidini
  • 216
  • 1
  • 8
0

Is the 'week' field as week of year, a date or other?

If it's a datetime, and you have datetime library imported , use .dt.to_period('M') on your current date column to create a new 'month' column, then get the max date for each month to get the date to sample ( if you only want the LAST date in each month ? )

Like max(df['MyDateField'])

Someone else is posting as I type this, so may have a better answer :)