Python ';系列';对象没有属性';数值单位计数';

Python ';系列';对象没有属性';数值单位计数';,python,pandas,dataframe,series,Python,Pandas,Dataframe,Series,当我尝试将values\u count()方法应用于函数中的序列时,我被告知“series”对象没有属性“values\u counts” def replace_1_occ_feat(col_list, df): for col in col_list: feat_1_occ = df[col].values_counts()[df[col].values_counts() == 1].index feat_means = df[col].groupb

当我尝试将values\u count()方法应用于函数中的序列时,我被告知“series”对象没有属性“values\u counts”

def replace_1_occ_feat(col_list, df):
    for col in col_list:
        feat_1_occ = df[col].values_counts()[df[col].values_counts() == 1].index 
        feat_means = df[col].groupby(col)['SalePrice'].mean()
        feat_means_no_1_occ = feat_means.iloc[feat_means.difference(feat_1_occ),:]
        for feat in feat_1_occ:
            # Find the closest mean SalePrice
            replacement = (feat_means_no_1_occ - feat_means.iloc[feat,:]).idxmin()
            df.col.replace(feat, replacement, inplace = True)
但是,当在函数外部运行df.column.values_count()时,它可以工作

当使用values_counts()方法时,问题出现在第一行。
我检查了熊猫的版本,它是0.23.0

函数是
值\u计数()
。注意只有count是复数。

应该是
值\u计数()
,而不是
值\u计数()
。若你们像我告诉你们的那个样修好它,问题就会解决