我有带有“Indicator_Name”字段的数据框,其中包含一些文本,我正在应用一些返回 2 个值并需要在数据框中更新相同值的函数
函数“String_Year_Pick_V2”返回两个值,如“XYZ”、“ABC”,需要针对每个“Indicator_Name”添加这些值
我试过下面的脚本:
DataT[['Indicator 2', 'Year']] = DataT['Indicator_Name'].apply(String_Year_Pick_V2, axis=1)
Error:
TypeError: String_Year_Pick_V2() got an unexpected keyword argument 'axis'
DataT[['Indicator 2', 'Year']] = DataT['Indicator_Name'].apply(String_Year_Pick_V2)
Error: ValueError: shape mismatch: value array of shape (252,) could not be broadcast to indexing result of shape (2,252
脚本:DataT['Indicator_Name'].apply(String_Year_Pick_V2) - 给出结果
DataT[['Indicator 2', 'Year']] = DataT.apply(lambda Row: String_Year_Pick_V2(Row['Indicator_Name']), axis=1)
Error: ValueError: shape mismatch: value array of shape (252,) could not be broadcast to indexing result of shape (2,252)
MMMHUHU
相关分类