我有以下数据帧:
In [18]: import pandas as pd
In [32]: df = pd.DataFrame.from_items([("A\tbar", [1, 2, 3]), ("B\tfoo" , [4, 5, 6])],orient='index', columns=['one', 'two', 'three'])
In [33]: df
Out[35]:
one two three
A\tbar 1 2 3
B\tfoo 4 5 6
In [34]: df.to_csv("tmp.csv" , sep='\t', encoding='utf-8', doublequote=False)
最终写入的文件如下所示(请注意,行名称中的双引号也仍然存在,我们想删除它):
^{pr2}$我要做的是将行名称的列命名为 最终创建的文件(tmp.csv版)公司名称:
alpha othername one two three
A bar 1 2 3
B foo 4 5 6
怎么做?在
感谢布伦巴恩
index=False
相关问题 更多 >
编程相关推荐