Skip to content

Commit

Permalink
guess_regex was not used correctly
Browse files Browse the repository at this point in the history
If guess_regex was used in _get_axis_coord, all keys would use the identified time column because it was not being limited to just T and time. Now it is.
  • Loading branch information
kthyng committed Mar 21, 2023
1 parent 9f5002a commit d80e157
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cf_pandas/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _get_axis_coord(obj: Union[DataFrame, Series], key: str) -> list:
# also use the guess_regex approach by default, but only if no results so far
# this takes the logic from cf-xarray guess_coord_axis
if len(results) == 0:
if obj[col].ndim == 1 and _is_datetime_like(obj[col]):
if key in ("T", "time") and _is_datetime_like(obj[col]):
results.update((col,))
continue # prevent second detection

Expand Down

0 comments on commit d80e157

Please sign in to comment.