Skip to content

Commit

Permalink
Merge pull request #18 from kthyng/main
Browse files Browse the repository at this point in the history
forgot to bring split into accessor
  • Loading branch information
kthyng authored Dec 9, 2022
2 parents 6a79ff3 + 2dbdc55 commit 39ab8fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cf_pandas/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
14 changes: 10 additions & 4 deletions tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"]

0 comments on commit 39ab8fe

Please sign in to comment.