Pandas KeyError: value not in index

后端 未结 4 951
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 14:06

I have the following code,

df = pd.read_csv(CsvFileName)

p = df.pivot_table(index=[\'Hour\'], columns=\'DOW\', values=\'Changes\', aggfunc=np.mean).round(0         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 15:07

    please try this to clean and format your column names:

    df.columns = (df.columns.str.strip().str.upper()
                  .str.replace(' ', '_')
                  .str.replace('(', '')
                  .str.replace(')', ''))
    

提交回复
热议问题