| 4269 | |
| 4270 | @derived_from(pd.Series) |
| 4271 | def value_counts( |
| 4272 | self, |
| 4273 | sort=None, |
| 4274 | ascending=False, |
| 4275 | dropna=True, |
| 4276 | normalize=False, |
| 4277 | split_every=None, |
| 4278 | split_out=no_default, |
| 4279 | ): |
| 4280 | if split_out is no_default: |
| 4281 | if isinstance(self.dtype, CategoricalDtype): |
| 4282 | # unobserved or huge categories will lead to oom errors |
| 4283 | if self.cat.known: |
| 4284 | split_out = 1 + len(self.dtype.categories) // 100_000 |
| 4285 | else: |
| 4286 | split_out = True |
| 4287 | else: |
| 4288 | split_out = True |
| 4289 | if split_out == 1 and split_out is not True and sort is None: |
| 4290 | sort = True |
| 4291 | |
| 4292 | length = None |
| 4293 | if (split_out > 1 or split_out is True) and normalize: |
| 4294 | frame = self if not dropna else self.dropna() |
| 4295 | length = Len(frame) |
| 4296 | |
| 4297 | return new_collection( |
| 4298 | ValueCounts( |
| 4299 | self, sort, ascending, dropna, normalize, split_every, split_out, length |
| 4300 | ) |
| 4301 | ) |
| 4302 | |
| 4303 | @derived_from(pd.Series) |
| 4304 | def mode(self, dropna=True, split_every=False): |