| 4295 | |
| 4296 | @derived_from(pd.Series) |
| 4297 | def value_counts( |
| 4298 | self, |
| 4299 | sort=None, |
| 4300 | ascending=False, |
| 4301 | dropna=True, |
| 4302 | normalize=False, |
| 4303 | split_every=None, |
| 4304 | split_out=no_default, |
| 4305 | ): |
| 4306 | if split_out is no_default: |
| 4307 | if isinstance(self.dtype, CategoricalDtype): |
| 4308 | # unobserved or huge categories will lead to oom errors |
| 4309 | if self.cat.known: |
| 4310 | split_out = 1 + len(self.dtype.categories) // 100_000 |
| 4311 | else: |
| 4312 | split_out = True |
| 4313 | else: |
| 4314 | split_out = True |
| 4315 | if split_out == 1 and split_out is not True and sort is None: |
| 4316 | sort = True |
| 4317 | |
| 4318 | length = None |
| 4319 | if (split_out > 1 or split_out is True) and normalize: |
| 4320 | frame = self if not dropna else self.dropna() |
| 4321 | length = Len(frame) |
| 4322 | |
| 4323 | return new_collection( |
| 4324 | ValueCounts( |
| 4325 | self, sort, ascending, dropna, normalize, split_every, split_out, length |
| 4326 | ) |
| 4327 | ) |
| 4328 | |
| 4329 | @derived_from(pd.Series) |
| 4330 | def mode(self, dropna=True, split_every=False): |