python经常在pandas数据处理中,使用append合并两个dataframe时
df = df.append(dff, ignore_index=True).drop_duplicates(keep=‘first’, inplace=False)
报如下警告
FutureWarning: Sorting because non-concatenation axis is not aligned. A future version of pandas will change to not sort by default. To accept the future behavior, pass ‘sort=False’. To retain the current behavior and silence the warning, pass ‘sort=True’. sort=sort)
怎么去掉警告?
解决办法:将sort=True或False放到append中,就不会报这个错误了
实例:
df= df.append(dff, ignore_index=True, sort=True).drop_duplicates(keep=‘first’, inplace=False)