我有一个日期间隔的数据框。你知道吗
必须按此数据框的前两列分组,然后填补空白。你知道吗
我尝试的是:
df.groupby(['cod_interno', 'unidade_lojas', 'data']).apply(lambda x : x.resample('D').ffill()).reset_index(level=0,drop=True)
但是,我收到了以下错误消息:
TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'
有没有更好的方法来解决这个问题?你知道吗
我尝试过这种方法Resampling a multi-index DataFrame,但对“stack()”不太熟悉
我相信您可以将^{} 与列
data
和datetimes一起使用,然后在groupby
之后使用resample
,lambda
函数是不必要的:相关问题 更多 >
编程相关推荐