-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: concat doesn't preserve attrs (as alternative for append deprecated in 1.4) #45824
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
Comments
There is some discussion on what the behavior should be in #28283, but perhaps it is worthy of an issue on its own. |
related #41828 |
I think concat only keeps the attrs only when they match by design. Re-labeling as enhancement. |
moving to 1.4.3 |
Even Hence, if you swap the order you call the import pandas as pd
df1 = pd.DataFrame({"a": [1]})
df2 = pd.DataFrame({"a": [2]})
df1.attrs["metadata-xy"] = 42
print("No attributes preserved: ",df2.append(df1).attrs) About |
removing milestone. as now it is late in the 1.4.x series of releases any fixes probably not now suitable for backport. |
contributions and PRs welcome. |
There is a related bug to
The concat raises an Exception:
If removing either the The question is of course: what is the expected behavior? I am not sure. Maybe an |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
append
preserves attrs, butconcat
doesn'tOriginally reported here #35407 (comment)
Expected Behavior
df1.append(df2).attrs
andpandas.concat([df1, df2]).attrs
should probably matchInstalled Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: