Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: box argument in to_datetime and to_timedelta #24416

Closed
mroeschke opened this issue Dec 24, 2018 · 4 comments · Fixed by #24486
Closed

DEPR: box argument in to_datetime and to_timedelta #24416

mroeschke opened this issue Dec 24, 2018 · 4 comments · Fixed by #24486
Labels
Datetime Datetime data dtype Deprecate Functionality to remove in pandas Timedelta Timedelta data type
Milestone

Comments

@mroeschke
Copy link
Member

Following @jreback #24415 (comment), we should deprecate the box argument in to_datetime and to_timedelta and only return pandas data structures. There already exists options to convert to numpy data structures via .values or to_datetime64/to_timedelta64

@shoyer
Copy link
Member

shoyer commented Jan 27, 2019

We find the option box=False quite useful in xarray, to let us leverage pandas for converting inputs into NumPy's timedelta64 and datetime64 dtypes.

I would be a little sad to see it go away, though of course coercing into NumPy arrays is pretty orthogonal to the goals of pandas.

@jreback
Copy link
Contributor

jreback commented Jan 27, 2019

use .to_numpy() if you must

@jorisvandenbossche
Copy link
Member

You cannot use to_numpy for scalars, as the example of @shoyer is in #24957 (comment)

(with 0.23.4)

In [58]: pd.to_timedelta('NaT', box=False)
Out[58]: numpy.timedelta64('NaT','ns')

In [59]: pd.to_timedelta('NaT', box=True)
Out[59]: NaT

In [60]: type(pd.to_timedelta('NaT', box=True))
Out[60]: pandas._libs.tslibs.nattype.NaTType

@jorisvandenbossche
Copy link
Member

OK, but I see there is #24653 for adding to_numpy to scalars as well.

For the specific case above, however, the problem is that we don't have a NaT for timedelta, so you would still get np.datetime64('NaT', 'ns')

@jreback jreback added this to the 0.25.0 milestone Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Deprecate Functionality to remove in pandas Timedelta Timedelta data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants