[英]Merge multiple spreadsheets with pd.merge
I am trying to merge multiple spreadsheets together on Python. I have the same header titles for each column in the same order with the same data types.我正在尝试将 Python 上的多个电子表格合并在一起。对于具有相同数据类型的相同顺序的每一列,我都有相同的 header 标题。 The only differences between the four are the actual data points in the cell.
四个之间的唯一区别是单元格中的实际数据点。 Here's what I mean
这就是我的意思
df1 : df1 :
Header 1 ![]() |
Header 2 ![]() |
Header 3 ![]() |
Header 4 ![]() |
---|---|---|---|
X ![]() |
A![]() |
M![]() |
1 ![]() |
Y![]() |
B![]() |
T![]() |
2 ![]() |
df2 : df2 :
Header 1 ![]() |
Header 2 ![]() |
Header 3 ![]() |
Header 4 ![]() |
---|---|---|---|
G ![]() |
J![]() |
H ![]() |
5 ![]() |
B![]() |
Q![]() |
L![]() |
8 ![]() |
df3 : df3 :
Header 1 ![]() |
Header 2 ![]() |
Header 3 ![]() |
Header 4 ![]() |
---|---|---|---|
E![]() |
U ![]() |
D![]() |
6 ![]() |
Z ![]() |
P ![]() |
S![]() |
3 ![]() |
The dtypes
for the dfs are as follows: dtypes
的数据类型如下:
I basically just want to stack the data from all of the data frames on top of one another, like this:我基本上只想将所有数据帧中的数据堆叠在一起,如下所示:
Header 1 ![]() |
Header 2 ![]() |
---|---|
X ![]() |
A![]() |
Y![]() |
B![]() |
G ![]() |
J![]() |
B![]() |
Q![]() |
E![]() |
U ![]() |
Z ![]() |
P ![]() |
...and so on for header 3 & 4. Any way I can do this with pd.merge? ...等等 header 3 和 4。我可以用 pd.merge 做到这一点吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.