@@ -410,52 +410,6 @@ def astype(self, dtype, copy=True):
410410 data = self .to_numpy (na_value = na_value )
411411 return astype_nansafe (data , dtype , copy = False )
412412
413- def value_counts (self , dropna = True ):
414- """
415- Returns a Series containing counts of each category.
416-
417- Every category will have an entry, even those with a count of 0.
418-
419- Parameters
420- ----------
421- dropna : bool, default True
422- Don't include counts of NaN.
423-
424- Returns
425- -------
426- counts : Series
427-
428- See Also
429- --------
430- Series.value_counts
431-
432- """
433-
434- from pandas import Index , Series
435-
436- # compute counts on the data with no nans
437- data = self ._data [~ self ._mask ]
438- value_counts = Index (data ).value_counts ()
439- array = value_counts .values
440-
441- # TODO(extension)
442- # if we have allow Index to hold an ExtensionArray
443- # this is easier
444- index = value_counts .index .values .astype (bool ).astype (object )
445-
446- # if we want nans, count the mask
447- if not dropna :
448-
449- # TODO(extension)
450- # appending to an Index *always* infers
451- # w/o passing the dtype
452- array = np .append (array , [self ._mask .sum ()])
453- index = Index (
454- np .concatenate ([index , np .array ([np .nan ], dtype = object )]), dtype = object
455- )
456-
457- return Series (array , index = index )
458-
459413 def _values_for_argsort (self ) -> np .ndarray :
460414 """
461415 Return values for sorting.
0 commit comments