|
40 | 40 | cache_readonly,
|
41 | 41 | deprecate_kwarg,
|
42 | 42 | )
|
43 |
| -from pandas.util._validators import ( |
44 |
| - validate_bool_kwarg, |
45 |
| - validate_fillna_kwargs, |
46 |
| -) |
| 43 | +from pandas.util._validators import validate_bool_kwarg |
47 | 44 |
|
48 | 45 | from pandas.core.dtypes.cast import (
|
49 | 46 | coerce_indexer_dtype,
|
|
105 | 102 | sanitize_array,
|
106 | 103 | )
|
107 | 104 | from pandas.core.indexers import deprecate_ndim_indexing
|
108 |
| -from pandas.core.missing import interpolate_2d |
109 | 105 | from pandas.core.ops.common import unpack_zerodim_and_defer
|
110 | 106 | from pandas.core.sorting import nargsort
|
111 | 107 | from pandas.core.strings.object_array import ObjectStringArrayMixin
|
@@ -1752,67 +1748,6 @@ def to_dense(self):
|
1752 | 1748 | )
|
1753 | 1749 | return np.asarray(self)
|
1754 | 1750 |
|
1755 |
| - def fillna(self, value=None, method=None, limit=None): |
1756 |
| - """ |
1757 |
| - Fill NA/NaN values using the specified method. |
1758 |
| -
|
1759 |
| - Parameters |
1760 |
| - ---------- |
1761 |
| - value : scalar, dict, Series |
1762 |
| - If a scalar value is passed it is used to fill all missing values. |
1763 |
| - Alternatively, a Series or dict can be used to fill in different |
1764 |
| - values for each index. The value should not be a list. The |
1765 |
| - value(s) passed should either be in the categories or should be |
1766 |
| - NaN. |
1767 |
| - method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None |
1768 |
| - Method to use for filling holes in reindexed Series |
1769 |
| - pad / ffill: propagate last valid observation forward to next valid |
1770 |
| - backfill / bfill: use NEXT valid observation to fill gap |
1771 |
| - limit : int, default None |
1772 |
| - (Not implemented yet for Categorical!) |
1773 |
| - If method is specified, this is the maximum number of consecutive |
1774 |
| - NaN values to forward/backward fill. In other words, if there is |
1775 |
| - a gap with more than this number of consecutive NaNs, it will only |
1776 |
| - be partially filled. If method is not specified, this is the |
1777 |
| - maximum number of entries along the entire axis where NaNs will be |
1778 |
| - filled. |
1779 |
| -
|
1780 |
| - Returns |
1781 |
| - ------- |
1782 |
| - filled : Categorical with NA/NaN filled |
1783 |
| - """ |
1784 |
| - value, method = validate_fillna_kwargs( |
1785 |
| - value, method, validate_scalar_dict_value=False |
1786 |
| - ) |
1787 |
| - value = extract_array(value, extract_numpy=True) |
1788 |
| - |
1789 |
| - if value is None: |
1790 |
| - value = np.nan |
1791 |
| - if limit is not None: |
1792 |
| - raise NotImplementedError( |
1793 |
| - "specifying a limit for fillna has not been implemented yet" |
1794 |
| - ) |
1795 |
| - |
1796 |
| - if method is not None: |
1797 |
| - # pad / bfill |
1798 |
| - |
1799 |
| - # TODO: dispatch when self.categories is EA-dtype |
1800 |
| - values = np.asarray(self).reshape(-1, len(self)) |
1801 |
| - values = interpolate_2d(values, method, 0, None).astype( |
1802 |
| - self.categories.dtype |
1803 |
| - )[0] |
1804 |
| - codes = _get_codes_for_values(values, self.categories) |
1805 |
| - |
1806 |
| - else: |
1807 |
| - # We copy even if there is nothing to fill |
1808 |
| - codes = self._ndarray.copy() |
1809 |
| - mask = self.isna() |
1810 |
| - |
1811 |
| - new_codes = self._validate_setitem_value(value) |
1812 |
| - np.putmask(codes, mask, new_codes) |
1813 |
| - |
1814 |
| - return self._from_backing_data(codes) |
1815 |
| - |
1816 | 1751 | # ------------------------------------------------------------------
|
1817 | 1752 | # NDArrayBackedExtensionArray compat
|
1818 | 1753 |
|
|
0 commit comments