[英]CSV Python Append Header after Data has been input
I have a CSV file in which I have already got all the data inside and I simply just need to write the header to the file without having to rewrite the whole file. 我有一个CSV文件,其中已经包含了所有数据,我只需要将标头写入文件中,而不必重写整个文件。
Example before: 之前的示例:
Jim Bob
Sam Ham
Example after: 以下示例:
FirstName LastName
------------------
Jim Bob
Sam Ham
Assuming df is your dataframe 假设df是您的数据框
df.columns = ["First_Name", "Last_Name"
] df.columns = ["First_Name", "Last_Name"
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.