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

REF: move logic of 'block manager axis' into the BlockManager #40075

Merged
merged 8 commits into from
Mar 5, 2021

Conversation

jorisvandenbossche
Copy link
Member

@jreback @jbrockmendel what are your thoughts about doing this?
Currently the 0/1 -> 1/0 axis switch for the BlockManager happens on the DataFrame side, while I think it would be a bit cleaner to let this be the responsibility of the BlockManager method being called.

For illustration, the diff of this PR is such a change for the diff() method: instead of using _get_block_manager_axis in frame.py, it's the BlockManager.diff() method that takes care of this (so just moving it down a level).

@jorisvandenbossche jorisvandenbossche marked this pull request as draft February 26, 2021 11:33
@jbrockmendel
Copy link
Member

+1

@jreback
Copy link
Contributor

jreback commented Feb 27, 2021

yep +1 on moving this to the BM.

@jorisvandenbossche jorisvandenbossche marked this pull request as ready for review March 1, 2021 13:36
@jorisvandenbossche
Copy link
Member Author

I also added the change for where and shift, in addition to diff. For keeping the PR small, that's probably enough for a first PR.

Other uses cases are eg in set_axis, reindex_indexer, take.

@jreback jreback added Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code labels Mar 4, 2021
@@ -385,7 +385,10 @@ def apply(

return type(self)(result_arrays, new_axes)

def apply_with_block(self: T, f, align_keys=None, **kwargs) -> T:
def apply_with_block(self: T, f, align_keys=None, swap_axis=True, **kwargs) -> T:
# switch axis to follow BlockManager logic
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed now that you have a _normalize_axis?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is still needed here because this is the function that does the "use block method as fallback" (and the block method is still using its inverted axis logic).

(but I am actively removing the usage of apply_with_block, like #40196)

@jreback
Copy link
Contributor

jreback commented Mar 5, 2021

can you merge master

@jreback jreback added this to the 1.3 milestone Mar 5, 2021
@jreback
Copy link
Contributor

jreback commented Mar 5, 2021

once more merge master pls

@jorisvandenbossche jorisvandenbossche merged commit bff0afd into pandas-dev:master Mar 5, 2021
@jorisvandenbossche jorisvandenbossche deleted the ref-bmaxis branch March 5, 2021 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants