Return a Series or DataFrame containing counts of unique rows. Parameters ---------- normalize : bool, default False Return proportions rather than frequencies. sort : bool, default True Sort by frequencies. ascending : bool,
(
self,
normalize: bool = False,
sort: bool = True,
ascending: bool = False,
bins=None,
dropna: bool = True,
)
| 1088 | ) |
| 1089 | |
| 1090 | def value_counts( |
| 1091 | self, |
| 1092 | normalize: bool = False, |
| 1093 | sort: bool = True, |
| 1094 | ascending: bool = False, |
| 1095 | bins=None, |
| 1096 | dropna: bool = True, |
| 1097 | ) -> Series | DataFrame: |
| 1098 | """ |
| 1099 | Return a Series or DataFrame containing counts of unique rows. |
| 1100 | |
| 1101 | Parameters |
| 1102 | ---------- |
| 1103 | normalize : bool, default False |
| 1104 | Return proportions rather than frequencies. |
| 1105 | sort : bool, default True |
| 1106 | Sort by frequencies. |
| 1107 | ascending : bool, default False |
| 1108 | Sort in ascending order. |
| 1109 | bins : int or list of ints, optional |
| 1110 | Rather than count values, group them into half-open bins, |
| 1111 | a convenience for pd.cut, only works with numeric data. |
| 1112 | dropna : bool, default True |
| 1113 | Don't include counts of rows that contain NA values. |
| 1114 | |
| 1115 | Returns |
| 1116 | ------- |
| 1117 | Series or DataFrame |
| 1118 | Series if the groupby ``as_index`` is True, otherwise DataFrame. |
| 1119 | |
| 1120 | See Also |
| 1121 | -------- |
| 1122 | Series.value_counts: Equivalent method on Series. |
| 1123 | DataFrame.value_counts: Equivalent method on DataFrame. |
| 1124 | DataFrameGroupBy.value_counts: Equivalent method on DataFrameGroupBy. |
| 1125 | |
| 1126 | Notes |
| 1127 | ----- |
| 1128 | - If the groupby ``as_index`` is True then the returned Series will have a |
| 1129 | MultiIndex with one level per input column. |
| 1130 | - If the groupby ``as_index`` is False then the returned DataFrame will have an |
| 1131 | additional column with the value_counts. The column is labelled 'count' or |
| 1132 | 'proportion', depending on the ``normalize`` parameter. |
| 1133 | |
| 1134 | By default, rows that contain any NA values are omitted from |
| 1135 | the result. |
| 1136 | |
| 1137 | By default, the result will be in descending order so that the |
| 1138 | first element of each group is the most frequently-occurring row. |
| 1139 | |
| 1140 | Examples |
| 1141 | -------- |
| 1142 | >>> s = pd.Series( |
| 1143 | ... [1, 1, 2, 3, 2, 3, 3, 1, 1, 3, 3, 3], |
| 1144 | ... index=["A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B"], |
| 1145 | ... ) |
| 1146 | >>> s |
| 1147 | A 1 |
nothing calls this directly
no test coverage detected