我的CSV文件:(星期一,星期二和星期三之间是空白单元格)
Monday Tuesday Wednesday
Items Price Items Price Items Price
Mon 1 Tues 1 Wed 1
Mon2 2 Tues2 2 Wed2 2
如何读取特定的表格?
我想要的结果:
df['Monday']
>>
Items Price
Mon 1
Mon2 2
df['Tuesday']['Items'].values()
>>
['Tues', 'Tues2']
这可能吗?
答案 0 :(得分:0)
如果您正在使用.read_csv的熊猫,则可以指定列标题
#exemple file 2 lines of headers:
df=pd.read_csv('filename', header=[0, 1])
来源: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html