|
52 | 52 | isidentifier, set_function_name)
|
53 | 53 | import pandas.core.nanops as nanops
|
54 | 54 | from pandas.util.decorators import Appender, Substitution, deprecate_kwarg
|
| 55 | +from pandas.util.validators import validate_bool_kwarg |
55 | 56 | from pandas.core import config
|
56 | 57 |
|
57 | 58 | # goal is to be able to define the docs close to function, while still being
|
@@ -733,6 +734,7 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
|
733 | 734 | 1 2 5
|
734 | 735 | 2 3 6
|
735 | 736 | """
|
| 737 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
736 | 738 | non_mapper = is_scalar(mapper) or (is_list_like(mapper) and not
|
737 | 739 | is_dict_like(mapper))
|
738 | 740 | if non_mapper:
|
@@ -1950,6 +1952,7 @@ def drop(self, labels, axis=0, level=None, inplace=False, errors='raise'):
|
1950 | 1952 | -------
|
1951 | 1953 | dropped : type of caller
|
1952 | 1954 | """
|
| 1955 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
1953 | 1956 | axis = self._get_axis_number(axis)
|
1954 | 1957 | axis_name = self._get_axis_name(axis)
|
1955 | 1958 | axis, axis_ = self._get_axis(axis), axis
|
@@ -2099,6 +2102,7 @@ def sort_values(self, by, axis=0, ascending=True, inplace=False,
|
2099 | 2102 | @Appender(_shared_docs['sort_index'] % dict(axes="axes", klass="NDFrame"))
|
2100 | 2103 | def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
|
2101 | 2104 | kind='quicksort', na_position='last', sort_remaining=True):
|
| 2105 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
2102 | 2106 | axis = self._get_axis_number(axis)
|
2103 | 2107 | axis_name = self._get_axis_name(axis)
|
2104 | 2108 | labels = self._get_axis(axis)
|
@@ -2872,6 +2876,7 @@ def consolidate(self, inplace=False):
|
2872 | 2876 | -------
|
2873 | 2877 | consolidated : type of caller
|
2874 | 2878 | """
|
| 2879 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
2875 | 2880 | if inplace:
|
2876 | 2881 | self._consolidate_inplace()
|
2877 | 2882 | else:
|
@@ -3267,6 +3272,7 @@ def convert_objects(self, convert_dates=True, convert_numeric=False,
|
3267 | 3272 | @Appender(_shared_docs['fillna'] % _shared_doc_kwargs)
|
3268 | 3273 | def fillna(self, value=None, method=None, axis=None, inplace=False,
|
3269 | 3274 | limit=None, downcast=None):
|
| 3275 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
3270 | 3276 | if isinstance(value, (list, tuple)):
|
3271 | 3277 | raise TypeError('"value" parameter must be a scalar or dict, but '
|
3272 | 3278 | 'you passed a "{0}"'.format(type(value).__name__))
|
@@ -3479,6 +3485,7 @@ def replace(self, to_replace=None, value=None, inplace=False, limit=None,
|
3479 | 3485 | and play with this method to gain intuition about how it works.
|
3480 | 3486 |
|
3481 | 3487 | """
|
| 3488 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
3482 | 3489 | if not is_bool(regex) and to_replace is not None:
|
3483 | 3490 | raise AssertionError("'to_replace' must be 'None' if 'regex' is "
|
3484 | 3491 | "not a bool")
|
@@ -3714,6 +3721,7 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False,
|
3714 | 3721 | """
|
3715 | 3722 | Interpolate values according to different methods.
|
3716 | 3723 | """
|
| 3724 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
3717 | 3725 |
|
3718 | 3726 | if self.ndim > 2:
|
3719 | 3727 | raise NotImplementedError("Interpolate has not been implemented "
|
@@ -4627,6 +4635,7 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
|
4627 | 4635 | Equivalent to public method `where`, except that `other` is not
|
4628 | 4636 | applied as a function even if callable. Used in __setitem__.
|
4629 | 4637 | """
|
| 4638 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
4630 | 4639 |
|
4631 | 4640 | cond = com._apply_if_callable(cond, self)
|
4632 | 4641 |
|
@@ -4894,6 +4903,7 @@ def where(self, cond, other=np.nan, inplace=False, axis=None, level=None,
|
4894 | 4903 | def mask(self, cond, other=np.nan, inplace=False, axis=None, level=None,
|
4895 | 4904 | try_cast=False, raise_on_error=True):
|
4896 | 4905 |
|
| 4906 | + inplace = validate_bool_kwarg(inplace, 'inplace') |
4897 | 4907 | cond = com._apply_if_callable(cond, self)
|
4898 | 4908 |
|
4899 | 4909 | return self.where(~cond, other=other, inplace=inplace, axis=axis,
|
|
0 commit comments