A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/50829 below:

DataFrame.count_values supports single label · Issue #50829 · pandas-dev/pandas · GitHub

Pandas version checks Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.value_counts.html

Documentation problem

documentation claims the subset must be list-like, optional

the implementation uses DataFrame.groupby, which accepts mapping, function, label, or list of labels

the result is value_counts can accept a single label

In [1]: import pandas as pd

In [2]: pd.__version__
Out[2]: '1.5.2'

In [3]: df = pd.DataFrame({"XYZ": ["foo", "foo", "foo", "foo", "foo"]})

In [4]: df.value_counts("XYZ")
Out[4]: 
XYZ
foo    5
dtype: int64
Suggested fix for documentation
  1. change the value_counts documentation to reflect its capabilities
  2. change the value_counts implementation to reflect the documentation

use of groupby goes to value_count's inception, and groupby's api has been consistent since 1.0

+1 option (1)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4