绑定使用 Pandas 数据框 Apply() 函数来更新具有函数的所有行。结果是一个类型错误----> 1 df_usnews['AvgMathSAT_IQR'].apply(interquartile(df_usnews))/anaconda/lib/python3.5/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds) 2235 values = lib.map_infer(values, boxer) 2236 -> 2237 mapped = lib.map_infer(values, f, convert=convert_dtype) 2238 if len(mapped) and isinstance(mapped[0], Series): 2239 from pandas.core.frame import DataFramepandas/src/inference.pyx in pandas.lib.map_infer (pandas/lib.c:63043)()TypeError: 'Series' object is not callabledef interquartile(df): return pd.to_numeric(df.ThirdQuartileMathSAT) - pd.to_numeric(df.FirstQuartileMathSAT)q75_upper = np.percentile(df_usnews.AvgMathSAT, q=75, interpolation='higher', axis=0)q25_lower = np.percentile(df_usnews.AvgMathSAT, q=25, interpolation='lower', axis=0)interquartile = q75_upper - q25_lowerdf_usnews['AvgMathSAT_IQR'] = 0df_usnews['AvgMathSAT_IQR'].apply(interquartile(df_usnews))
添加回答
举报
0/150
提交
取消