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 shift logic from BlockManager to DataFrame #40536

Merged
merged 6 commits into from
Mar 23, 2021

Conversation

jbrockmendel
Copy link
Member

Partially-fixes one of the currently-disabled ArrayManager tests.

@jbrockmendel jbrockmendel added Internals Related to non-user accessible pandas implementation Refactor Internal refactoring of code labels Mar 22, 2021
)
tail = self.iloc[:, -periods:]
# pin a simple Index to avoid costly casting
tail.columns = range(len(tail.columns))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we guaranteed to copy here?

Copy link
Member Author

Choose a reason for hiding this comment

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

copy what?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh. tail is not necessarily a copy of the data in self, but we do make a copy in the concat call below, so the result we return is always a copy

Copy link
Contributor

Choose a reason for hiding this comment

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

right that's the problem you are actually modifying the input here (e.g. you are setting columns).

Copy link
Member Author

Choose a reason for hiding this comment

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

tail is never the same object as self, just may be a view on it

Copy link
Contributor

Choose a reason for hiding this comment

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

got it ok

)
tail = self.iloc[:, -periods:]
# pin a simple Index to avoid costly casting
tail.columns = range(len(tail.columns))
Copy link
Contributor

Choose a reason for hiding this comment

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

got it ok

@jreback jreback added this to the 1.3 milestone Mar 23, 2021
@jreback jreback merged commit 9535280 into pandas-dev:master Mar 23, 2021
@jbrockmendel jbrockmendel deleted the ref-shift branch March 23, 2021 16:49
@jorisvandenbossche
Copy link
Member

I don't know if it's a particularly useful benchmark, but there is a big slowdown potentially related to this PR: https://pandas.pydata.org/speed/pandas/#frame_methods.Shift.time_shift?python=3.8&Cython=0.29.21&p-axis=1&commits=05a0e98a-bc62e768

@jbrockmendel
Copy link
Member Author

best guess is its bc a consolidate is being done by concat, which is called 2x. easy-ish workaround will be available following #38939

@jorisvandenbossche
Copy link
Member

I opened an issue to track my above comment -> #42246

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