Skip to content

Commit aa93aba

Browse files
authored
add support for drop_dims (#146)
1 parent 1a15e73 commit aa93aba

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

cf_xarray/accessor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ def _get_with_standard_name(
372372
_DEFAULT_KEY_MAPPERS: Mapping[str, Tuple[Mapper, ...]] = {
373373
"dim": (_get_axis_coord,),
374374
"dims": (_get_axis_coord,), # transpose
375+
"drop_dims": (_get_axis_coord,), # drop_dims
375376
"dimensions": (_get_axis_coord,), # stack
376377
"dims_dict": (_get_axis_coord,), # swap_dims, rename_dims
377378
"shifts": (_get_axis_coord,), # shift, roll

cf_xarray/tests/test_accessor.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,3 +708,11 @@ def test_drop_sel_and_reset_coords(obj):
708708
assert_identical(
709709
obj.reset_coords("air"), obj.cf.reset_coords("air_temperature")
710710
)
711+
712+
713+
@pytest.mark.parametrize("ds", datasets)
714+
def test_drop_dims(ds):
715+
716+
# Axis and coordinate
717+
for cf_name in ["X", "longitude"]:
718+
assert_identical(ds.drop_dims("lon"), ds.cf.drop_dims(cf_name))

doc/whats-new.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ What's New
66
v0.4.1 (unreleased)
77
===================
88

9-
- Support for ``.drop()``, ``.drop_vars()``, ``.drop_sel()``, ``.set_coords()``, ``.reset_coords()``. By `Mattia Almansi`_.
9+
- Support for ``.drop()``, ``.drop_vars()``, ``.drop_sel()``, ``.drop_dims()``, ``.set_coords()``, ``.reset_coords()``. By `Mattia Almansi`_.
1010
- Support for using ``standard_name`` in more functions. (:pr:`128`) By `Deepak Cherian`_
1111
- Allow ``DataArray.cf[]`` with standard names. By `Deepak Cherian`_
1212
- Rewrite the ``values`` of ``.cf.coords`` and ``.cf.data_vars`` with objects returned

0 commit comments

Comments
 (0)