랭귀지/pandas
                
              pandas concat
                유키공
                 2024. 7. 13. 10:42
              
              
                                
        import pandas as pd
df1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
df2 = pd.DataFrame({'C': [7, 8, 9], 'D': [10, 11, 12]})
# concat하고 결측치를 0으로 채운 후 reset_index
result = pd.concat([df1, df2], axis=0, sort=False).fillna(0).astype(int).reset_index(drop=True)
print(result)   A  B  C   D
0  1  4  0   0
1  2  5  0   0
2  3  6  0   0
3  0  0  7  10
4  0  0  8  11
5  0  0  9  12