Python Pandas read_csv保持列顺序 [英] Python Pandas read_csv Keep Column Order
本文介绍了Python Pandas read_csv保持列顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将CSV文件读入熊猫:
I am reading a CSV file into pandas:
df = pd.read_csv('file.csv')
但是,我注意到没有保留列顺序.我在文档中找不到任何说明来解释在读取CSV文件时如何保持列顺序的东西.
However, I notice that column order is not preserved. I can't find anything in the docs that explain how to keep the column order when reading in the CSV file.
推荐答案
read.csv
将表格数据转换为DataFrame
对象.由于DataFrame
是kwargs
词典,因此不能坚持使用顺序.
read.csv
convert tabular data into DataFrame
object. Since DataFrame
are kwargs
dictionary, order is not persevered.
这篇关于Python Pandas read_csv保持列顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文