我想从特定行制作数据标头,数据像这样csv file,我想使this row的数字是我要作为标头制作的特定数据,我尝试使用names=['string','string']
,但无法添加3个或更多列表。
我使用的数据:
NO","KECAMATAN","KELURAHAN","PUSKESMAS","JLH PENDUDUK","TERSANGKA","","","","IR","CFR (%)","PE"
"","","","","","JENIS KELAMIN","","TOTAL PENDERITA ","JML. MENINGGAL ","",""
"","","","","","LK","PR","","","","",""
我想将第1行1-5行和第3行6-7行,最后将第1行6行作为标题
输出将是这样的:
'NO','KECAMATAN','KELURAHAN','PUSKESMAS','LK','PR','TERSANGKA'
这是代码:
import pandas as pd
df = pd.read_csv('20162017.csv', usecols=[0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], skiprows=(0, 9), nrows=(54))
print (df)