如何在 python 中 append/concat 不相关的数据帧
how to append/concat unrelated dataframes in python
我想按如下所示的方式 append/concatenate 两个不相关的数据框:
输入
Table 1
col1
1
2
Table 2
col1
A
B
预期结果
col1
col
1
A
1
B
2
A
2
B
是否存在任何功能可以做到这一点?或者只有 for 循环才有可能?
你可以使用 pandas dataframe.concat 查看文档 https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html
我想按如下所示的方式 append/concatenate 两个不相关的数据框:
输入 Table 1
col1 |
---|
1 |
2 |
Table 2
col1 |
---|
A |
B |
预期结果
col1 | col |
---|---|
1 | A |
1 | B |
2 | A |
2 | B |
是否存在任何功能可以做到这一点?或者只有 for 循环才有可能?
你可以使用 pandas dataframe.concat 查看文档 https://pandas.pydata.org/pandas-docs/stable/user_guide/merging.html