Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace is_datetime_or_timedelta_dtype #316

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions opensearch_py_ml/field_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
from pandas.core.dtypes.common import is_bool_dtype # type: ignore
from pandas.core.dtypes.common import (
is_datetime64_any_dtype,
is_datetime_or_timedelta_dtype,
is_float_dtype,
is_integer_dtype,
is_string_dtype,
is_timedelta64_dtype,
)
from pandas.core.dtypes.inference import is_list_like

Expand Down Expand Up @@ -91,7 +91,9 @@ def is_numeric(self) -> bool:

@property
def is_timestamp(self) -> bool:
return is_datetime_or_timedelta_dtype(self.pd_dtype)
return is_datetime64_any_dtype(self.pd_dtype) or is_timedelta64_dtype(
self.pd_dtype
)

@property
def is_bool(self) -> bool:
Expand Down Expand Up @@ -509,7 +511,7 @@ def _pd_dtype_to_os_dtype(pd_dtype) -> Optional[str]:
os_dtype = "boolean"
elif is_string_dtype(pd_dtype):
os_dtype = "keyword"
elif is_datetime_or_timedelta_dtype(pd_dtype):
elif is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype):
os_dtype = "date"
elif is_datetime64_any_dtype(pd_dtype):
os_dtype = "date"
Expand Down Expand Up @@ -794,7 +796,9 @@ def metric_source_fields(
pd_dtypes.append(np.dtype(pd_dtype))
os_field_names.append(os_field_name)
os_date_formats.append(os_date_format)
elif include_timestamp and is_datetime_or_timedelta_dtype(pd_dtype):
elif include_timestamp and (
is_datetime64_any_dtype(pd_dtype) or is_timedelta64_dtype(pd_dtype)
):
pd_dtypes.append(np.dtype(pd_dtype))
os_field_names.append(os_field_name)
os_date_formats.append(os_date_format)
Expand Down
Loading