240108
import pandas as pd
import numpy as np
df1 = pd.DataFrame({
'Class1' : [95, 92, 98, 100],
'Class2' : [91, 93, 97, 99]
})
df2 = pd.DataFrame({
'Class1' : [87,89],
'Class2' : [85,90]
})
df2
df1.append(df2) # 판다스버전 1.4.0 이후로 append 지원하지않음
판다스 공식페이지 참조하여 대처하기
https://pandas.pydata.org/pandas-docs/version/1.4/reference/api/pandas.DataFrame.append.html
pandas.DataFrame.append — pandas 1.4.4 documentation
Sort columns if the columns of self and other are not aligned. Changed in version 1.0.0: Changed to not sort by default.
pandas.pydata.org
deprecated = 미래에 사용하지 않을수있다
result = pd.concat([df1,df2])
result
df3 = pd.DataFrame({
'Class1' :[96, 83]
})
pd.concat([result,df3], ignore_index=True)
#가로방향으로 통합하기
- pd.concat()
df4 = pd.DataFrame ({
'Class3' :[93, 91, 95, 98]
})
df1.join(df4)
index_label = ['a','b','c','d']
df1a = pd.DataFrame({'Class1': [95, 92, 98, 100],
'Class2': [91, 93, 97, 99]}, index= index_label)
df4a = pd.DataFrame({'Class3': [93, 91, 95, 98]}, index=index_label)
df1a.join(df4a)