Pandas: Getting “TypeError: only integer scalar arrays can be converted to a scalar index” while trying to merge data frames

前端 未结 2 1736
天涯浪人
天涯浪人 2021-01-05 12:04

After renaming a DataFrame\'s column(s), I get an error when merging on the new column(s):

import pandas as pd

df1 = pd.DataFrame({\'a\': [1, 2         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-05 12:35

    Replaced the code tmp.columns = [['POR','POR_PORT']] with tmp.rename(columns={'Locode':'POR', 'Port Name':'POR_PORT'}, inplace=True) and it worked.

提交回复
热议问题