Month, date, temperature (°C) precipitation (mm) wind speed (m/s) solar radiation (MJ/m2)
2017-01-01 00:00:00 5.8 0.0 1.5 0.0
2017-01-01 01:00:00 4.9 0.0 0.8 0.0
2017-01-01 02:00:00 4.9 0.0 1.5 0.0
2017-01-01 03:00:00 4.2 0.0 0.8 0.0
2017-01-01 04:00:00 4.4 0.0 1.0 0.0
Convert these hourly data into minute-by-minute data, and the value between is a copy of the previous value. I'd like to, but I don't know how to write it.Could you please let me know?
Month, date, temperature (°C) precipitation (mm) wind speed (m/s) solar radiation (MJ/m2)
2017-01-01 00:00:00 5.8 0.0 1.5 0.0
2017-01-01 00:01:00 5.8 0.0 1.5 0.0
2017-01-01 00:02:00 5.8 0.0 1.5 0.0
・・・・・
I would like to do so.
Thank you for your cooperation.
Set the DatetimeIndex to
resample('1min').ffill()
I think it would be good to
Just a sample.
importio
import pandas aspd
data=""
Date and time of year, temperature (°C), precipitation (mm), wind speed (m/s), solar radiation (MJ/m2)
2017-01-01 00:00:00,5.8,0.0,1.5,0.0
2017-01-01 01:00:00,4.9,0.0,0.8,0.0
2017-01-01 02:00:00,4.9,0.0,1.5,0.0
2017-01-01 03:00:00,4.2,0.0,0.8,0.0
2017-01-01 04:00:00,4.4,0.0,1.0,0.0
"""
df = pd.read_csv (io.StringIO(data), parse_dates = ['year and date', index_col = 'year and date')
new_df = df.resample('1min').ffill()
print(new_df)
© 2024 OneMinuteCode. All rights reserved.