-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
MAINT: Drop convert_objects from NDFrame #15757
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
Conversation
""" attempt to coerce any object types to better types return a copy of | ||
the block (if copy = True) by definition we ARE an ObjectBlock!!!!! | ||
""" | ||
Attempt to coerce any object types to more specific data types. |
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.
there's a whole bunch of code here that i think u can ditch now that was for compat with 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.
What do you mean by compat with convert_objects
? How so?
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.
most of this code iirc was to support multiple convert args at the same time (via convert_objects) which is not needed by convert - look at the blame and u shall see
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 don't really follow you here. convert_objects
was nowhere in the implementation of convert
, and it seems like this function is used as a pathway to the replacement for the object
conversion functions (e.g. to_timedelta
)
Codecov Report
@@ Coverage Diff @@
## master #15757 +/- ##
==========================================
- Coverage 90.96% 90.96% -0.01%
==========================================
Files 161 143 -18
Lines 49301 49416 +115
==========================================
+ Hits 44849 44953 +104
- Misses 4452 4463 +11
Continue to review full report at Codecov.
|
@@ -1845,12 +1845,13 @@ def is_bool(self): | |||
""" | |||
return lib.is_bool_array(self.values.ravel()) | |||
|
|||
# TODO: Refactor when convert_objects is removed since there will be 1 path |
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.
look and see when this comment was put in
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.
all of the fn_kwargs stuff can go back
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.
be removed i mean
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.
Yeah, I did. #11173 - I'm not sure I follow what the logic was back then.
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.
Remove fn_kwargs
? convert
appears to be just a wrapper around all of the object conversion functions as I mentioned above. Doesn't that allow us to pass in keyword arguments specific to each of those functions?
@jorisvandenbossche you would have to make a clear case for a useful conversion function not sure it's worth the name either i would suggest a recipe or expand to_* to a) 2-d b) add a soft option |
See my comment in #11221 (comment) (at that time I was convinced of its usefulness, would have to dig in again for the details), and some of the other reactions. |
@jorisvandenbossche i saw your comment reviving a bad api is not going to happen |
@gfyoung what I mean is that _possibly_convert_objects should just become part of This new function is pretty much what @jorisvandenbossche is looking for and potentially could be exposed. It allows soft & hard conversions. I just ran all tests. It seems that with this PR.
|
I think it would be worth exposing whatever the new soft convert api is 0.20 (I haven't looked at it in detail), referencing it in the I say this because I know there are people (for example, me) who have ignored the df = pd.read_html(source)[0] # poorly formatted table, everything inferred to object
# exact columns can vary
df.columns = df.loc[0, :]
df = df.drop(0).dropna()
df = df.convert_objects() Looking at this again, I realize |
@jorisvandenbossche @chris-b1 : You both raise some valid arguments regarding the keeping of |
it was deprecated because of the magic "if it has 1 valid value convert it, but if nothing converts then revert it" (maybe should make a song!) So it becomes data dependent, not a great thing for a default. Sure it could be an option to the user which would be fine. This further was exacerbated because the conversion would first try to convert to datetime, then if that failed to timdelta, then to numeric. Even more magic here. So certainly we could add this back, but it would have to be an explict user decision. |
this is basically what it does on top of the current functions: #11221 (comment) |
My opinion of The real issue here is that the well-defined rules for converting objects have already failed by the time that If there was a need for a |
05e7910
to
6eb86ff
Compare
@jreback : |
69eeb52
to
145adda
Compare
@gfyoung btw, no reason for you to keep rebasing this, unless something is actually changing. |
Yeah, sorry, I have been making changes locally, but I haven't pushed anything yet. |
np by all means if u r changing things |
145adda
to
9b64ba2
Compare
i think this is fine even IF we want to have a future conversion function could always bring back the name i am |
I am -1 on merging this before a resolution on #11221 |
e47b85d
to
8f5c9bd
Compare
22839ea
to
8feab44
Compare
e501b44
to
cf81b37
Compare
9ef4cda
to
ffe4361
Compare
@jorisvandenbossche I don't think waiting on this is healthy. We haven't had any activity w.r.t. #11221. if someone really needs this then a new API can be designed. |
57dc4db
to
73b67d7
Compare
73b67d7
to
f84278a
Compare
Deprecated since 0.17.0 xref pandas-devgh-11173 [ci skip]
f84278a
to
b18e93c
Compare
yes, let's close this and proceed as indicated in #11221, create |
Deprecated since 0.17.0
xref #11173