如何将具有多个标题行的 csv 文件读入 Pandas?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43853300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 03:33:29  来源:igfitidea点击:

How to read a csv file with multiple header rows into pandas?

pythoncsvpandasheaderjupyter-notebook

提问by Caribgirl

I am not sure how to read the multiple rows. Do i have to do it without the rows and then do it manually in pandas? Or is there a way to read the whole csv file into pandas?

我不确定如何读取多行。我是否必须在没有行的情况下进行操作,然后在 Pandas 中手动进行操作?或者有没有办法将整个 csv 文件读入Pandas?

This is how the file looks Poverty data

这是文件的外观 贫困数据

回答by jezrael

You need parameter header=[0,1]in read_csv.

你需要参数header=[0,1]read_csv