import pandas as pd
import numpy as np
data = pd.read_excel('/Users/xujingfei/Desktop/成都补货数据.xlsx',engine='openpyxl')
data['岳阳库存'].fillna(0,inplace=True)
data.set_index(inplace=True,keys=['sp','品名','SP计数','8折采购价', '补货方式','岳阳库存', '成都库存','总补货量'])
data.rename_axis('收货仓库',axis='columns',inplace=True)
df = data.stack()
k = df.reset_index()
k.rename(columns={0:'value'},inplace=True)
print(k.columns)
print(k)
k.to_excel('/Users/xujingfei/Desktop/成都补货数据1.xlsx',index=False)
标签:index,data,列名,inplace,补货,修改,True,stack,columns
From: https://www.cnblogs.com/ivan09/p/17038950.html