pandas操作Excel列变行
方法1:
df.T.to_excel(filename,index=False,header = False)
方法2:
def read_excel(select, save):
global df
filenames = os.listdir(select)
with pandas.ExcelWriter(save + '\\test.xls') as writer:
for index, filename in enumerate(filenames):
file_path = select + '\\' + filename;
file = open(file_path, 'rb');
data = pandas.read_excel(file, sheet_name='外径1', header=34, usecols=[2]);
df = pandas.DataFrame(data);
df.rename(columns={'值': filename}, inplace=True)
df.to_excel(writer, sheet_name='Sheet1', startrow=index, index=False)