Skip to content

ENH: Add suffixes for pd.concat when axis=1 #29615

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
charlesdong1991 opened this issue Nov 14, 2019 · 1 comment
Closed

ENH: Add suffixes for pd.concat when axis=1 #29615

charlesdong1991 opened this issue Nov 14, 2019 · 1 comment

Comments

@charlesdong1991
Copy link
Member

charlesdong1991 commented Nov 14, 2019

When I was trying to horizontally concatenate several DataFrames which contain some overlapping column names, and those overlapping columns would remain unchanged. However, it might be quite useful to have a suffixes argument as e.g DataFrame.merge has in practice, so that could easily add meaningful suffix to distinguish those overlapped columns. And this argument will be used only when axis=1.

While a walkaround for this is: pd.merge(df1, df2, left_index=True, right_index=True), but this cannot be applied in more dfs.

Just found out that this might be similar to #21791 and if this is the arg we want to add, I would be happy to work on this.

Minimum reproducible code:

>>> df1 = pd.DataFrame({"a": [1, 2, 3], "b": [2, 3, 4]})
>>> df2 = pd.DataFrame({"a": [4, 5, 6], "b": [7, 8, 9]})
>>> pd.concat([df1, df2], axis=1)

a | b | a | b
-- | -- | -- | --
1 | 2 | 4 | 7
2 | 3 | 5 | 8
3 | 4 | 6 | 9
@charlesdong1991
Copy link
Member Author

Duplicate

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

1 participant