python - 'Series' object has no attribute 'values_counts ...
stackoverflow.com › questions › 54557423Feb 06, 2019 · When I try to apply the values_count () method to series within a function, I am told that 'Series' object has no attribute 'values_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 = ...
numpy.ndarray' object has no attribute 'value_counts' Code ...
www.codegrepper.com › code-examples › pythonOct 08, 2020 · numpy.ndarray' object has no attribute 'value_counts' Code Example. >>> a = numpy.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4])>>> unique, counts = numpy.unique(a, return_counts=True)>>> dict(zip(unique, counts)){0: 7, 1: 4, 2: 1, 3: 2, 4: 1} Follow. GREPPER.