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
Currently box=True is specified in the docstring to return a DatetimeIndex, but sometimes this is not possible due to how the dates are parsed and a different Index subclass is returned. However, this policy is not consistent:
In [8]: pd.__version__
Out[8]: '0.24.0.dev0+312.gd48f34141.dirty'
In [9]: idx = pd.Index([15e9], name='name')
In [10]: pd.to_datetime(idx, errors='ignore', box=True, unit='s') # Index returned
Out[10]: Float64Index([15000000000.0], dtype='float64')
In [11]: pd.to_datetime(idx, errors='ignore', box=False, unit='s')
Out[11]: array([15000000000.0], dtype=object)
In [12]: malformed = np.array(['1/100/2000', np.nan], dtype=object)
In [13]: pd.to_datetime(malformed, errors='ignore', box=True) # Index not returned
Out[13]: array(['1/100/2000', nan], dtype=object)
In [14]: pd.to_datetime(malformed, errors='ignore', box=False)
Out[14]: array(['1/100/2000', nan], dtype=object)
For consistency, I think box=True should always attempt to wrap the argument in an Index
Currently
box=True
is specified in the docstring to return a DatetimeIndex, but sometimes this is not possible due to how the dates are parsed and a different Index subclass is returned. However, this policy is not consistent:For consistency, I think
box=True
should always attempt to wrap the argument in anIndex
Addressing this in #21822
The text was updated successfully, but these errors were encountered: