Skip to content

REF: simplify _sanitize_column #38459

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 4 commits into from
Dec 14, 2020
Merged

Conversation

jbrockmendel
Copy link
Member

It gets called indirectly from iloc._setitem_with_indexer, which we're trying to simplify

@@ -3210,15 +3212,47 @@ def _setitem_frame(self, key, value):
self._check_setitem_copy()
self._where(-key, value, inplace=True)

def _set_item_frame_value(self, key, value: "DataFrame"):
Copy link
Contributor

Choose a reason for hiding this comment

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

add return type (None)

# reindex if necessary

if value.index.equals(index) or not len(index):
value = value._values.copy()
Copy link
Contributor

Choose a reason for hiding this comment

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

can you just return here?

else:

# GH#4107
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

avoids nesting this

return value


def _maybe_atleast_2d(value):
Copy link
Contributor

Choose a reason for hiding this comment

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

can likley use elsewhere

Copy link
Contributor

Choose a reason for hiding this comment

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

could put in core/dtypes/cast

Copy link
Member Author

Choose a reason for hiding this comment

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

ill take a look; most likely place it would be used is in internals

@jreback jreback added Refactor Internal refactoring of code Indexing Related to indexing on series/frames, not to indexes themselves labels Dec 14, 2020
@jreback jreback added this to the 1.3 milestone Dec 14, 2020
@jreback jreback merged commit 35cc565 into pandas-dev:master Dec 14, 2020
@jreback
Copy link
Contributor

jreback commented Dec 14, 2020

thanks, yeah we have a lot of built up code over the years. +1 on organizaing / simplifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants