diff --git a/cf_pandas/accessor.py b/cf_pandas/accessor.py index eed4a5f..05cd085 100644 --- a/cf_pandas/accessor.py +++ b/cf_pandas/accessor.py @@ -42,5 +42,5 @@ def __getitem__(self, key: str): xarray Dataset of the data associated with key """ - col_name = cfp.match_criteria_key(self._obj.columns.values, key) + col_name = cfp.match_criteria_key(self._obj.columns.values, key, split=True) return self._obj[col_name] diff --git a/tests/test_accessor.py b/tests/test_accessor.py index 5703bac..5212897 100644 --- a/tests/test_accessor.py +++ b/tests/test_accessor.py @@ -21,10 +21,16 @@ def test_options(): def test_match_criteria_key_accessor(): - vals = ["wind_speed", "WIND_SPEED", "wind_speed_status"] - - df = pd.DataFrame(columns=["temp", "wind_speed"]) + df = pd.DataFrame( + columns=[ + "temp", + "wind_speed", + "wind_speed (m/s)", + "WIND_SPEED", + "wind_speed_status", + ] + ) # test accessor with set_options criteria with cfp.set_options(custom_criteria=criteria): - assert df.cf["wind_s"].columns == ["wind_speed"] + assert sorted(df.cf["wind_s"].columns) == ["wind_speed", "wind_speed (m/s)"]