time A B C ... N time A B C ... N
1/1 a c 1/1 aa cc
1/2 b d 1/2 bb dd ....
... ...
W1 W2
上面显示了几个DataFrames(W1,W2,...),它们表示A到N的不同属性。如何合并这些DataFrame中的相同列名称,以便可以在一个DataFrame中显示一列的不同属性?
预期输出:
time W1 W2 ... time W1 W2 ...
1/1 a aa 1/1 c cc
1/2 b bb 1/2 d dd ...
... ...
A B
答案 0 :(得分:0)
基于此https://pandas.pydata.org/pandas-docs/stable/merging.html
如果我正确理解,则需要执行:
import pandas as pd
new_df = pd.concat([W1, W2, W3])
答案 1 :(得分:0)
尝试一下
import pandas as pd
# there are 2 dfs by df1 and df2 and both have column A
df1A = df.loc[df['A']]
df2A = df.loc[df['A']]
final_df = pd.concat([df1A,df2A], sort=True)