You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two Series, both containing years. One series is dtype == float64 and the other is dtype == object. When I apply pd.to_datetime() to these two columns, i get drastically different results.
While I understand why this difference exists (perhaps there's an assumption being made that if dtype == float, then the value are epoch nanoseconds?), I'm not sure I agree with the inconsistency in behavior based strictly on dtype. I would favor a solution that treated the float64 series the same as the string/object series. Is it possible that the logic that infers year_string as containing years could also be applied to year_float?
The text was updated successfully, but these errors were encountered:
I'm going to close this is as a duplicate of #15836 You are are right that the floats are being treated as ordinals - #15836 would have it raise an error unless a unit was specified as this behavior can be surprising. So agree this should be fixed!
That said, as a general rule - you should expect different dtypes to do different things. '1995' and 1995.0 are rarely interchangeable in pandas.
I have two Series, both containing years. One series is
dtype == float64
and the other isdtype == object
. When I apply pd.to_datetime() to these two columns, i get drastically different results.While I understand why this difference exists (perhaps there's an assumption being made that if dtype == float, then the value are epoch nanoseconds?), I'm not sure I agree with the inconsistency in behavior based strictly on dtype. I would favor a solution that treated the float64 series the same as the string/object series. Is it possible that the logic that infers
year_string
as containing years could also be applied toyear_float
?The text was updated successfully, but these errors were encountered: