Skip to content

Commit 3211ed8

Browse files
committed
PR feedback: issue reference and whatsnew
1 parent b4d4558 commit 3211ed8

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

doc/source/whatsnew/v1.4.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Other enhancements
129129
- :meth:`DataFrame.__pos__`, :meth:`DataFrame.__neg__` now retain ``ExtensionDtype`` dtypes (:issue:`43883`)
130130
- The error raised when an optional dependency can't be imported now includes the original exception, for easier investigation (:issue:`43882`)
131131
- Added :meth:`.ExponentialMovingWindow.sum` (:issue:`13297`)
132+
- :meth:`Categorical.value_counts` now supports the argument ``observed`` (:issue:`43498`)
132133

133134
.. ---------------------------------------------------------------------------
134135

pandas/tests/extension/test_categorical.py

+2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def test_value_counts(self, all_data, dropna):
164164
return super().test_value_counts(all_data, dropna)
165165

166166
def test_value_counts_observed(self, data):
167+
# GH 43498
168+
# When observed=True is passed, unobserved categories should be omitted
167169
data = data.add_categories(["#", "?"]) # Add some unobserved categories
168170
series = pd.Series(data, dtype=data.categories.dtype)
169171
result = data.value_counts(observed=True).sort_index()

0 commit comments

Comments
 (0)