0

I have a monthly value which I would like to change to daily data;

Date        Ireland    UK   France
01/09/2020  42         87   84
01/10/2020  85         45   65
01/11/2020  45         42   89
01/12/2020  45         15   41
01/01/2020  34         41   35

But would like it to be daily eg. each monthly value represents the daily value within that month.

Eg


Date       Ireland    UK   France
01/09/2020 42         87   84
02/09/2020 42         87   84
03/09/2020 42         87   84
.
.
.
.
06/10/2020 85         45  65
07/10/2020 85         45  65

etc

Any help much appreciated!

spcol
  • 437
  • 4
  • 15

1 Answers1

2

Cast to datetime and then use resample with a forward fill:

df['Date'] = pd.to_datetime(df.Date, format='%d/%m/%Y')
df.set_index('Date').resample('D').ffill()

            Ireland  UK  France
Date                           
2020-01-01       34  41      35
2020-01-02       34  41      35
2020-01-03       34  41      35
2020-01-04       34  41      35
2020-01-05       34  41      35
...             ...  ..     ...
2020-11-27       45  42      89
2020-11-28       45  42      89
2020-11-29       45  42      89
2020-11-30       45  42      89
2020-12-01       45  15      41
yatu
  • 86,083
  • 12
  • 84
  • 139