重命名轴上的熊猫错误传递的参数错误

时间:2019-02-20 08:07:00

标签: pandas

我有一个数据框,该数据框返回在一个时间范围内完成的销售计数,该计数存储到变量total_sale_count

total_sale_count_old = pd.DataFrame(total_sale_count, columns=['TotalSaleCount'])
total_stop_count = total_sale_count_old.set_index('TotalSaleCount').T.rename_axis('Total Sales').rename_axis(None, 1).reset_index()

以上抛出错误

TypeError: rename_axis() takes from 1 to 2 positional arguments but 3 were given

1 个答案:

答案 0 :(得分:0)

我相信您需要:

total_sale_count = pd.Series([1,2,3], index=list('abc'))

total_stop_count = pd.DataFrame([total_sale_count], index=['TotalSaleCount'])
print (total_stop_count)
                a  b  c
TotalSaleCount  1  2  3