@@ -204,6 +204,25 @@ def isna(self):
204
204
"""
205
205
raise AbstractMethodError (self )
206
206
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
+
207
226
# ------------------------------------------------------------------------
208
227
# Indexing methods
209
228
# ------------------------------------------------------------------------
@@ -235,9 +254,8 @@ def take(self, indexer, allow_fill=True, fill_value=None):
235
254
236
255
Examples
237
256
--------
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
241
259
242
260
.. code-block:: python
243
261
@@ -246,6 +264,10 @@ def take(self, indexer, allow_fill=True, fill_value=None):
246
264
result = self.data.take(indexer)
247
265
result[mask] = self._fill_value
248
266
return type(self)(result)
267
+
268
+ See Also
269
+ --------
270
+ numpy.take
249
271
"""
250
272
raise AbstractMethodError (self )
251
273
@@ -305,14 +327,6 @@ def _can_hold_na(self):
305
327
"""
306
328
return True
307
329
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
-
316
330
@property
317
331
def _ndarray_values (self ):
318
332
# type: () -> np.ndarray
0 commit comments