Open ntachukwu opened 2 years ago
Simple reproducer:
result = np.array([1000000, 200000, 3000000], dtype="timedelta64[s]")
result_pandas = pd.Series([1000000, 200000, 3000000], dtype="timedelta64[s]")
tm.assert_numpy_array_equal(result, result_pandas.values)
This should pass, but we seem to ignore the seconds and interpret it as nanoseconds
This is currently not supported and should raise imo rather than returning buggy conversions
cc @jbrockmendel
This is currently not supported and should raise imo rather than returning buggy conversions
Agreed.
Also will be supported in 2.0, so just need a temporary patch for 1.4.x/1.5.x
cc @mroeschke @jreback this becomes more salient with non-nano support. pd.Series([1, 2, 3], dtype="m8[s]")
i think ideally should interpret those integers as seconds, but without an API change it will interpret them as nanoseconds, then cast the result to m8[s]
. Interpreting them as seconds would also be consistent with pd.Series([1, 2 , 3]).astype("m8[s]")
That sounds reasonable; it also make it effectively similar to to_timedelta([ints], unit="s")
which in spirit mangles "unit" and "reso" but may not matter.
cc @jreback
possible deprecation cycles notwithstanding, my preferred behavior would be for pd.Series(some_ints, dtype="m8[unit]").to_numpy()
to match np.array(some_ints, dtype="m8[unit]")
. i'd do the same for dt64 dtypes.
proposal sounds good
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
This code passes
But when dtype="timedelta64[s]" and unit="s" it returns
Expected Behavior
Both series should be equal.
Installed Versions