我有一个带有以下标头的CSV
,Appreciation Return,,Income Return,,Total Return,,Cap Rate,,NCREIF Value Index,,10 Yr T-Bond,,
,Base,Aternative High Interest Rates,Base,Aternative High Interest Rates,Base,Aternative High Interest Rates,Base,Aternative High Interest Rates,Base,Aternative High Interest Rates,Base,Aternative High Interest Rates,
我尝试了标准调用:
df = pd.read_csv(f, header=[0,1], skiprows=3, skipinitialspace=True, tupleize_cols=True)
这不起作用,因为标题中有空的东西。此数据最初是从Excel中导出的,Excel中已合并了单元格。他们不再加入。熊猫是否有可能接管最后一个标头单元并将其保留,因为它以“稀疏”(更好的术语是“我”)格式存储?
我期望具有类似
的多索引Appreciation Return>Base; Appreciation Return>Aternative High Interest Rates
但是得到:
Appreciation Return>Base; NA>Aternative High Interest Rates