Skip to content

CLN: simplify maybe_convert_objects, soft_convert_objects #27444

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

Merged
merged 15 commits into from
Jul 20, 2019

Conversation

jbrockmendel
Copy link
Member

Block.replace has code for dispatching to either maybe_convert_objects or soft_convert_objects, but the former is only reached from the tests. So rip that out and use soft_convert_objects.

Both of the functions have branches that are unreachable, so rip those out, along with adding types and validation.

@jbrockmendel jbrockmendel changed the title CLN: simplify maybe_convery_objects, soft_convert_objects CLN: simplify maybe_convert_objects, soft_convert_objects Jul 18, 2019

else:
values = lib.maybe_convert_objects(values, convert_datetime=convert_dates)
if values.dtype == np.object_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use is_object_dtype

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

values = lib.maybe_convert_objects(
values, convert_timedelta=convert_timedeltas
)
if values.dtype == np.object_:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -2780,44 +2784,39 @@ 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
def convert(self, *args, **kwargs):
def convert(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side issue is that a lot of this can be cleaned up now that convert_objects is gone

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that deprecation was before I got here, so it isn't clear to me what else can be cleaned up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just remove the comment, you have cleaned up reasonably. you can try looking in history but if not ok.

@jreback jreback added Clean Internals Related to non-user accessible pandas implementation labels Jul 20, 2019
numeric: bool = True,
timedelta: bool = True,
coerce: bool = False,
):
""" attempt to coerce any object types to better types return a copy of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add typing to the returns would be good here (and maybe Paramters / Returns to the doc-string), but can be in the future. I think adding doc-strings on routines that we are most likely going to keep is worth the effort (so use your judgement on this).

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. ping on green.

@jreback jreback added this to the 1.0 milestone Jul 20, 2019
@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit 8f4295a into pandas-dev:master Jul 20, 2019
@jreback
Copy link
Contributor

jreback commented Jul 20, 2019

thanks

@jbrockmendel jbrockmendel deleted the convert_objects branch July 20, 2019 23:52
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants