我想打开一个csv文件,转置(或交换)行和列,然后只将一列写入新文件。输出文件应该有73行长,但每次我得到这个输出:Province/State NaNCountry/Region LebanonLat 33.8547Long 35.86231/22/20 0 ... 3/26/20 3683/27/20 3913/28/20 4123/29/20 4383/30/20 446Name: 147, Length: 73, dtype: object这是蟒蛇代码:import pandas as pdinp_file = pd.read_csv('input_file.csv')out_file = inp_file.T#I have also tried out_file=inp_file.transpose()f = open("output_file.csv", "w")f.write(str(out_file[147]))f.close()有没有办法在输出文件中将完整的原始行作为列获取?谢谢
添加回答
举报
0/150
提交
取消