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

PERF: concat([Series, DataFrame], axis=0) returns RangeIndex columns when possible #58119

Merged
merged 3 commits into from Apr 3, 2024

Conversation

mroeschke
Copy link
Member

Discovered in #57441

@mroeschke mroeschke added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Index Related to the Index class or subclasses labels Apr 2, 2024
@mroeschke mroeschke added this to the 3.0 milestone Apr 2, 2024
obj = sample._constructor({name: obj}, copy=False)
obj = sample._constructor(obj, copy=False)
if isinstance(obj, ABCDataFrame):
obj.columns = range(name, name + 1, 1)
Copy link
Member

Choose a reason for hiding this comment

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

What type of Index gets returned by the constructor? Shouldn't we be creating the RangeIndex at a lower level?

Copy link
Member Author

Choose a reason for hiding this comment

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

._constructor with a dict would have returned an Index column with a single element name. With _constructor, there is currently no way to dictate the return type of the columns (if _constructor supports columns)

@WillAyd
Copy link
Member

WillAyd commented Apr 3, 2024

Conflict but otherwise lgtm

@mroeschke mroeschke merged commit 05ab1af into pandas-dev:main Apr 3, 2024
46 checks passed
@mroeschke mroeschke deleted the ref/ri/concat/mixed branch April 3, 2024 20:15
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
…when possible (pandas-dev#58119)

* PERF: concat([Series, DataFrame], axis=0) returns RangeIndex columns when possible

* Add whatsnew number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Index Related to the Index class or subclasses Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants