[英]python hdfs writer adds an extra index column to output csv
I need to write a csv to hdfs. 我需要将csv写入hdfs。 Currently i am using hdfs module for doing that.
目前,我正在使用hdfs模块来执行此操作。
df = pd.DataFrame(data, columns = ['FirstName','LastName','City'])
d = InsecureClient('http://localhost:50070')
with d.write(path, encoding = 'utf-8', overwrite=True) as writer:
df.to_csv(writer)
file is succesfully generated, but it adds and extra index column as starting to the csv. 文件已成功生成,但是它添加了额外的索引列作为csv的开始。 I need to have the file with the columns i have specified.
我需要具有指定的列的文件。 how i can remove this index?
我如何删除该索引? i could not find any parameter for that.
我找不到任何参数。
#current output:
,"FirstName","LastName","City"
0,"John","Doo","New York"
1,"Jane","Doo","San Francisco"
#expected:
"FirstName","LastName","City"
"John","Doo","New York"
"Jane","Doo","San Francisco"
thanks in advance, clairvoyant 在此先感谢,千里眼
update: using pandas package to create my csv 更新:使用熊猫包创建我的csv
调用to_csv
时将index=False
设置(默认为True
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.