0

I have a csv data with daily frequency as shown below:

d = pd.read_csv("DGS5.csv")
d['DATE'] = pd.to_datetime(d.DATE)
d.set_index('DATE', inplace=True)
print(d)

            DGS5
      DATE  
1962-01-02  3.88
1962-01-03  3.87
1962-01-04  3.86
1962-01-05  3.89
1962-01-08  3.91
... ...
2022-11-17  3.93
2022-11-18  3.99
2022-11-21  3.97
2022-11-22  3.93
2022-11-23  3.88

When I try to resample this to monthly frequency, I get the following output; where DATE column is DATE column is converted to monthly frequency by missing DGS5 values.

d.resample('1m').mean()

      DATE
2022-01-31
2022-02-28
2022-03-31
2022-04-30
2022-05-31
2022-06-30
2022-07-31
2022-08-31

Below the information about the data.

<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 15887 entries, 1962-01-02 to 2022-11-23
Data columns (total 1 columns):
 #   Column  Non-Null Count  Dtype 
---  ------  --------------  ----- 
 0   DGS5    15887 non-null  object
dtypes: object(1)

Appreciate support from the community to show where I am going wrong here.

sam
  • 71
  • 1
  • 3
  • 14

0 Answers0