Skip to content

REF: avoid using concat in __repr__ #26863

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

Closed
jbrockmendel opened this issue Jun 15, 2019 · 5 comments
Closed

REF: avoid using concat in __repr__ #26863

jbrockmendel opened this issue Jun 15, 2019 · 5 comments

Comments

@jbrockmendel
Copy link
Member

ATM DataFrame.__repr__ takes a path through io.formats.format.DataFrameFormatter._chk_truncate that can call core.reshape.concat.concat. Similar for Series.__repr__. It would be really nice if we could avoid that and find a simpler way to do this.

@jorisvandenbossche
Copy link
Member

Can you explain a bit more why you think this is bad?

@jbrockmendel
Copy link
Member Author

Can you explain a bit more why you think this is bad?

In the motivating example, in a WIP branch I managed to screw up DataFrame.__repr__ and debugging it was made more complicated by the use of concat.

My intuition is that concat is overkill for this particular usage and we can simplify the dependency structure here.

@jorisvandenbossche
Copy link
Member

I am not sure that is desirable / possible to avoid in practice. The concat ensures that the values above and below the truncation are formatted together, which is important for a consistent formatting (I remember bugs about this).
Of course you could also concat on the array level and not series/dataframe level, but not sure what the advantage of that would be.

@jreback
Copy link
Contributor

jreback commented Jun 16, 2019

you might be able to use an iloc /
take here instead (maybe) rather than concat

@jbrockmendel
Copy link
Member Author

I trust Joris if he says this is needed; closing. @jorisvandenbossche could use your input on #26864.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants