2024-04-18 20:04:52 发布
网友
我有年数据集要转换成季度数据集,通常我只想重复4次年度值,并将它们分配到当年的每个季度,谁能帮我?谢谢。在
您可以使用resample和ffill:
resample
ffill
df = pd.DataFrame({'date':pd.date_range('2001-01-01',periods=15, freq='AS'), 'Value_1':np.random.randint(0,100,15)}) df=df.set_index('date') df_out = df.resample('QS').ffill() print(df_out.head(10))
输出:
您可以使用
resample
和ffill
:输出:
^{pr2}$相关问题 更多 >
编程相关推荐