Skip to content

Commit 0f5e4f0

Browse files
committed
Docs
1 parent 1e8e87e commit 0f5e4f0

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

pandas/core/arrays/base.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,25 @@ def isna(self):
204204
"""
205205
raise AbstractMethodError(self)
206206

207+
def value_counts(self, dropna=True):
208+
"""Compute a histogram of the counts of non-null values.
209+
210+
Parameters
211+
----------
212+
dropna : bool, default True
213+
Don't include counts of NaN
214+
215+
Returns
216+
-------
217+
value_counts : Series
218+
"""
219+
from pandas import value_counts
220+
221+
if dropna:
222+
self = self[~self.isna()]
223+
224+
return value_counts(np.array(self))
225+
207226
# ------------------------------------------------------------------------
208227
# Indexing methods
209228
# ------------------------------------------------------------------------
@@ -235,9 +254,8 @@ def take(self, indexer, allow_fill=True, fill_value=None):
235254
236255
Examples
237256
--------
238-
Suppose the extension array somehow backed by a NumPy array and that
239-
the underlying structured array is stored as ``self.data``. Then
240-
``take`` may be written as
257+
Suppose the extension array is backed by a NumPy array stored as
258+
``self.data``. Then ``take`` may be written as
241259
242260
.. code-block:: python
243261
@@ -246,6 +264,10 @@ def take(self, indexer, allow_fill=True, fill_value=None):
246264
result = self.data.take(indexer)
247265
result[mask] = self._fill_value
248266
return type(self)(result)
267+
268+
See Also
269+
--------
270+
numpy.take
249271
"""
250272
raise AbstractMethodError(self)
251273

@@ -305,14 +327,6 @@ def _can_hold_na(self):
305327
"""
306328
return True
307329

308-
def value_counts(self, dropna=True):
309-
from pandas import value_counts
310-
311-
if dropna:
312-
self = self[~self.isna()]
313-
314-
return value_counts(np.array(self))
315-
316330
@property
317331
def _ndarray_values(self):
318332
# type: () -> np.ndarray

pandas/core/indexing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ def can_do_equal_len():
618618
return
619619

620620
if isinstance(value, (ABCSeries, dict)):
621-
# TODO: ExtensionBlock.setitem this causes issues with setting
622-
# for extensionarrays that store dicts. Need to decide if it's
623-
# worth supporting that or now
621+
# TODO(EA): ExtensionBlock.setitem this causes issues with
622+
# setting for extensionarrays that store dicts. Need to decide
623+
# if it's worth supporting that.
624624
value = self._align_series(indexer, Series(value))
625625

626626
elif isinstance(value, ABCDataFrame):

0 commit comments

Comments
 (0)