慕田峪4524236
这是因为您在列而不是行中应用了该函数。例子:data = pd.DataFrame([[np.NaN, 1], [np.NaN, 2], [np.NaN, 1]], columns=["age", "pclass"])print(data)输出 age pclass 0 NaN 1 1 NaN 2 2 NaN 1轴 = 0 data[['age','pclass']].apply(print, axis=0)输出0 None1 None2 NoneName: age, dtype: object0 11 22 1Name: pclass, dtype: object//Iterate through columns轴 = 1 data[['age','pclass']].apply(print, axis=1)输出 age Nonepclass 1Name: 0, dtype: objectage Nonepclass 2Name: 1, dtype: objectage Nonepclass 1Name: 2, dtype: object//Iterate through the row