我正在创建此功能:
def stand_col_names(*df_to_stand):
'''function that allow you to lowercase dataframes columns'''
df_to_stand.columns = df_to_stand.columns.str.lower()
return df_to_stand
如您所见,我的目标是同时传递多个数据帧以转换列名。像这样:
df1,df2,df3,df4 = stand_col_names(df1,df4)
我不想要一个只接受一个参数的函数,因此只写四行,每个数据帧一行。
当我运行它时,出现以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-c4c8e2ccc0f3> in <module>
----> 1 df_target_pm,df_target_sp=stand_col_names(df_target_pm,df_target_sp)
<ipython-input-18-65eb087bc145> in stand_col_names(*df_to_stand)
1 def stand_col_names(*df_to_stand):
2 '''function that allow you to lowercase dataframes columns'''
----> 3 df_to_stand.columns = df_to_stand.columns.str.lower()
4 return df_to_stand
AttributeError: 'tuple' object has no attribute 'columns'
能帮我吗?