Skip to content

Add doc for counting categorical dtype #59327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 30, 2024
Merged

Conversation

jahn96
Copy link
Contributor

@jahn96 jahn96 commented Jul 26, 2024


.. ipython:: python

df = pd.DataFrame({'a': [1], 'b': ['2'], 'c': [3], 'd': [3]}).astype({'a': 'category', 'c': 'category', 'd': 'category'})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this in the docstring instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed here

@@ -1178,3 +1180,9 @@ Use ``copy=True`` to prevent such a behaviour or simply don't reuse ``Categorica
This also happens in some cases when you supply a NumPy array instead of a ``Categorical``:
using an int array (e.g. ``np.array([1,2,3,4])``) will exhibit the same behavior, while using
a string array (e.g. ``np.array(["a","b","c","a"])``) will not.

Counting CategoricalDtype
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you undo the changes in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's still changes in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry! Addressed here

@@ -1049,6 +1049,34 @@ def value_counts(
4.0 1
NaN 1
Name: count, dtype: int64

**categorial_dtypes**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**categorial_dtypes**
**Categorial Dtypes**

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed here

@mroeschke mroeschke added Docs Categorical Categorical Data Type labels Jul 29, 2024
@jahn96 jahn96 requested a review from mroeschke July 30, 2024 02:15
@mroeschke mroeschke added this to the 3.0 milestone Jul 30, 2024
@mroeschke mroeschke merged commit 12c8ec4 into pandas-dev:main Jul 30, 2024
38 of 45 checks passed
@mroeschke
Copy link
Member

Thanks @jahn96

@jahn96 jahn96 deleted the categorical branch August 4, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG (?): dtype.value_counts() shows categorical multiple times
2 participants