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

Use pd.concat instead because df.append is deprecated #1209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thomasjpfan
Copy link
Member

pd.concat is deprecated in pandas 1.X and was removed in 2.0. XREF: pandas-dev/pandas#35407

pd.concat does not error if the columns do not match. It results in nan values:

import pandas as pd

df1 = pd.DataFrame(data={"col1": [10, 2], "col2": [10, 4]})
df2 = pd.DataFrame(data={"col3": [5, 10], "col4": [5, 10]})

print(pd.concat([df1, df2]).to_markdown())
col1 col2 col3 col4
0 10 10 nan nan
1 2 4 nan nan
0 nan nan 5 5
1 nan nan 10 10

Signed-off-by: Thomas J. Fan <thomasjpfan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants