我正在创建一个包含两列的 data_frame,然后将索引设置为这两列。所以它是空的,但有一个索引。然后我将它与另一个具有相同索引的 data_frame 结合起来。它有效,但我收到以下警告:
UserWarning:不同级别之间的合并可能会产生意想不到的结果(左侧 2 个级别,右侧 1 个) warnings.warn(msg, UserWarning)
我错过了什么吗?是否有一些意想不到的行为?我想摆脱警告。代码如下。我在代码中创建一个数据框,另一个从文件加载。
def forward_fill_dates(self, start_date, end_date):
dates = []
current_date = start_date
while current_date <= end_date:
dates.append({'Date': int(f'{current_date:%Y%m%d}'), 'Bin': 0})
current_date = bd.shift_day(current_date, 1)
date_df = pandas.DataFrame(dates).set_index(['Date', 'Bin'])
unstacked_df = self.other_data.unstack()
joined_df = pandas.merge(unstacked_df, date_df, how='outer', left_index=True, right_index=True)
self.other_df = joined_df.fillna(method='ffill').stack()
慕的地8271018
相关分类