Open hixan opened 2 weeks ago
Handling of time units and proper casting is missing when the numpy values are inside a python list instead of a numpy arrray:
pl.DataFrame({
# ok
"np_array_ns": np.array([np.timedelta64(1000000000, "ns"), np.timedelta64(1000000000, "ns")]),
# ok
"np_array_us": np.array([np.timedelta64(1000000, "us"), np.timedelta64(1000000, "us")]),
# ok
"np_array_ms": np.array([np.timedelta64(1000, "ms"), np.timedelta64(1000, "ms")]),
# ignores time unit
"py_list_ns": [np.timedelta64(1000000000, "ns"), np.timedelta64(1000000000, "ns")],
# TypeError
"py_list_us": [np.timedelta64(1000000, "us"), np.timedelta64(1000000, "us")],
# TypeError
"py_list_ms": [np.timedelta64(1000, "ms"), np.timedelta64(1000, "ms")],
})
Checks
Reproducible example
Log output
No response
Issue description
Polars does not seem to read the time unit associated with the numpy timedelta64, and instead assumes microsecond.
Expected behavior
The returned column should have the same time unit as the numpy object (in this case ns)
Installed versions