-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Restore original convert_objects and add _convert #11173
Conversation
Still a few things to do:
|
timedelta=True, | ||
coerce=False, | ||
# TODO: Remove in 0.18 or 2017, which ever is sooner | ||
def _possibly_convert_objects(values, convert_dates=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we put _possibly_convert_objects
and _soft_convert_objects
in pandas/tools/convert.py
(new file)
common.py
is just so huge. We can eventually move more stuff their as well. It will have to import common
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do this after as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll just note that there is some value in keeping this function intact in core._common
. Xray was using this private function internally, with a broken guard against it changing (see pydata/xarray#569 for details). Obviously, that was our fault and we've fixed it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shoyer I don't think you should be using this internal function (I saw you removed it). and instead use the public .convert_objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough -- but there's not any other way to hook directly into pandas' object array of datetimes -> datetime64 conversion. Might be worth thinking about making such an API at some point.
On Wed, Sep 23, 2015 at 5:58 PM, Jeff Reback notifications@github.com
wrote:
@@ -1857,23 +1857,84 @@ def _maybe_box_datetimelike(value):
_values_from_object = lib.values_from_object
-def _possibly_convert_objects(values,
datetime=True,
numeric=True,
timedelta=True,
coerce=False,
+# TODO: Remove in 0.18 or 2017, which ever is sooner
Reply to this email directly or view it on GitHub:
+def _possibly_convert_objects(values, convert_dates=True,
@shoyer I don't think you should be using this internal function (I saw you removed it). and instead use the public.convert_objects
https://github.com/pydata/pandas/pull/11173/files#r40276398
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean like this?
In [20]: pd.to_datetime([datetime.datetime(2012,1,1,0,0),datetime.datetime(2013,1,1,1,1)],box=False)
Out[20]:
array(['2011-12-31T19:00:00.000000000-0500',
'2012-12-31T20:01:00.000000000-0500'], dtype='datetime64[ns]')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite -- I only want soft conversion (like the pd.Series
constructor). I don't want to convert text that matches a regex, only an array of all datetime
instances (to datetime64) or all timedelta
instances (to timedelta64).
The important changes are:
This change requires this to 'route' to either the old or new style converter.
New function. |
@bashtage Really thanks a lot for this! (I am still not fully convinced the deprecation is needed, but I will try to summarize my reasons tomorrow) |
pls let me know asap. |
078042b
to
a5d655f
Compare
Still no tests for |
looks good! ping when tests for |
@jorisvandenbossche ok with this |
|
Yes - it definitely needs work. It expects something with the buffer On Sun, Sep 27, 2015 at 8:12 PM Joris Van den Bossche <
|
@bashtage did you have a chance to add some tests here? |
a5d655f
to
65b053c
Compare
Should be ready when green I think |
Can squash commits - wanted to make it easier to see changes at each stage since close to release |
@jreback Green - let me know if I missed anything. Only tick left is to add some docs although this can probably wait since |
@@ -48,3 +48,66 @@ def compose(*funcs): | |||
"""Compose 2 or more callables""" | |||
assert len(funcs) > 1, 'At least 2 callables must be passed to compose' | |||
return reduce(_compose2, funcs) | |||
|
|||
|
|||
def to_numeric(arg, errors='raise', box=True, coerce=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'coerce' shouldn't be here?
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
Restores the v0.16 behavior of convert_objects and moves the new
version of _convert
Adds to_numeric for directly converting numeric data
closes #11116
closes #11133