MCPcopy
hub / github.com/pydata/xarray / drop

Method drop

xarray/core/dataset.py:6004–6058  ·  view source on GitHub ↗

Backward compatible method based on `drop_vars` and `drop_sel` Using either `drop_vars` or `drop_sel` is encouraged See Also -------- Dataset.drop_vars Dataset.drop_sel

(
        self,
        labels=None,
        dim=None,
        *,
        errors: ErrorOptions = "raise",
        **labels_kwargs,
    )

Source from the content-addressed store, hash-verified

6002 return self._replace(variables=variables, indexes=indexes)
6003
6004 def drop(
6005 self,
6006 labels=None,
6007 dim=None,
6008 *,
6009 errors: ErrorOptions = "raise",
6010 **labels_kwargs,
6011 ) -> Self:
6012 """Backward compatible method based on `drop_vars` and `drop_sel`
6013
6014 Using either `drop_vars` or `drop_sel` is encouraged
6015
6016 See Also
6017 --------
6018 Dataset.drop_vars
6019 Dataset.drop_sel
6020 """
6021 if errors not in ["raise", "ignore"]:
6022 raise ValueError('errors must be either "raise" or "ignore"')
6023
6024 if is_dict_like(labels) and not isinstance(labels, dict):
6025 emit_user_level_warning(
6026 "dropping coordinates using `drop` is deprecated; use drop_vars.",
6027 FutureWarning,
6028 )
6029 return self.drop_vars(labels, errors=errors)
6030
6031 if labels_kwargs or isinstance(labels, dict):
6032 if dim is not None:
6033 raise ValueError("cannot specify dim and dict-like arguments.")
6034 labels = either_dict_or_kwargs(labels, labels_kwargs, "drop")
6035
6036 if dim is None and (is_scalar(labels) or isinstance(labels, Iterable)):
6037 emit_user_level_warning(
6038 "dropping variables using `drop` is deprecated; use drop_vars.",
6039 FutureWarning,
6040 )
6041 # for mypy
6042 if is_scalar(labels):
6043 labels = [labels]
6044 return self.drop_vars(labels, errors=errors)
6045 if dim is not None:
6046 warnings.warn(
6047 "dropping labels using list-like labels is deprecated; using "
6048 "dict-like arguments with `drop_sel`, e.g. `ds.drop_sel(dim=[labels]).",
6049 FutureWarning,
6050 stacklevel=2,
6051 )
6052 return self.drop_sel({dim: labels}, errors=errors, **labels_kwargs)
6053
6054 emit_user_level_warning(
6055 "dropping labels using `drop` is deprecated; use `drop_sel` instead.",
6056 FutureWarning,
6057 )
6058 return self.drop_sel(labels, errors=errors)
6059
6060 def drop_sel(
6061 self, labels=None, *, errors: ErrorOptions = "raise", **labels_kwargs

Callers 4

drop_selMethod · 0.45
test_drop_variablesMethod · 0.45

Calls 6

drop_varsMethod · 0.95
drop_selMethod · 0.95
is_dict_likeFunction · 0.90
emit_user_level_warningFunction · 0.90
either_dict_or_kwargsFunction · 0.90
is_scalarFunction · 0.90

Tested by 3

test_drop_variablesMethod · 0.36