pd.concat([df1, df2, df3], axis=1)
我可以使用某种“安全/严格的水平串联”方法来检查我的假设吗?
i在
pandahandler
软件包中写了SAFE_HSTACK精确解决此问题。然后:
import pandas as pd
df1 = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df2 = pd.DataFrame({"b": [7, 8, 9], "c": [10, 11, 12]})
df2.index = pd.Index([3, 4, 5])
df = pd.concat([df1, df2], axis=1)
print(df)