mirror of
https://github.com/elastic/eland.git
synced 2025-07-11 00:02:14 +08:00
Using the 'date' field for datetime64+timezone columns
This commit is contained in:
parent
3db93cd789
commit
64daa07a65
@ -34,6 +34,7 @@ import numpy as np
|
|||||||
import pandas as pd # type: ignore
|
import pandas as pd # type: ignore
|
||||||
from pandas.core.dtypes.common import ( # type: ignore
|
from pandas.core.dtypes.common import ( # type: ignore
|
||||||
is_bool_dtype,
|
is_bool_dtype,
|
||||||
|
is_datetime64_any_dtype,
|
||||||
is_datetime_or_timedelta_dtype,
|
is_datetime_or_timedelta_dtype,
|
||||||
is_float_dtype,
|
is_float_dtype,
|
||||||
is_integer_dtype,
|
is_integer_dtype,
|
||||||
@ -487,7 +488,7 @@ class FieldMappings:
|
|||||||
int64 int int_, int8, int16, int32, int64, uint8, uint16, uint32, uint64 Integer numbers
|
int64 int int_, int8, int16, int32, int64, uint8, uint16, uint32, uint64 Integer numbers
|
||||||
float64 float float_, float16, float32, float64 Floating point numbers
|
float64 float float_, float16, float32, float64 Floating point numbers
|
||||||
bool bool bool_ True/False values
|
bool bool bool_ True/False values
|
||||||
datetime64 NA datetime64[ns] Date and time values
|
datetime64 NA datetime64[ns] datetime64[ns, TIMEZONE] Date and time values
|
||||||
timedelta[ns] NA NA Differences between two datetimes
|
timedelta[ns] NA NA Differences between two datetimes
|
||||||
category NA NA Finite list of text values
|
category NA NA Finite list of text values
|
||||||
```
|
```
|
||||||
@ -505,6 +506,8 @@ class FieldMappings:
|
|||||||
es_dtype = "keyword"
|
es_dtype = "keyword"
|
||||||
elif is_datetime_or_timedelta_dtype(pd_dtype):
|
elif is_datetime_or_timedelta_dtype(pd_dtype):
|
||||||
es_dtype = "date"
|
es_dtype = "date"
|
||||||
|
elif is_datetime64_any_dtype(pd_dtype):
|
||||||
|
es_dtype = "date"
|
||||||
else:
|
else:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
f"No mapping for pd_dtype: [{pd_dtype}], using default mapping"
|
f"No mapping for pd_dtype: [{pd_dtype}], using default mapping"
|
||||||
|
@ -37,6 +37,7 @@ class TestDataFrameUtils(TestData):
|
|||||||
"E": [1.0, 2.0, 3.0],
|
"E": [1.0, 2.0, 3.0],
|
||||||
"F": False,
|
"F": False,
|
||||||
"G": [1, 2, 3],
|
"G": [1, 2, 3],
|
||||||
|
"H": pd.Timestamp("20190102", tz="UTC"),
|
||||||
},
|
},
|
||||||
index=["0", "1", "2"],
|
index=["0", "1", "2"],
|
||||||
)
|
)
|
||||||
@ -51,6 +52,7 @@ class TestDataFrameUtils(TestData):
|
|||||||
"E": {"type": "double"},
|
"E": {"type": "double"},
|
||||||
"F": {"type": "boolean"},
|
"F": {"type": "boolean"},
|
||||||
"G": {"type": "long"},
|
"G": {"type": "long"},
|
||||||
|
"H": {"type": "date"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user