print(row_concat.iloc[3, ])

new_row_series = pd.Series(['n1','n2','n3','n4'])

print(pd.concat([df1, new_row_series]))
import pandas as pd

df1 = pd.read_csv('./data/concat_1.csv')
df2 = pd.read_csv('./data/concat_2.csv')
df3 = pd.read_csv('./data/concat_3.csv')

row_concat = pd.concat([df1, df2, df3])

print(row_concat)
print(row_concat.iloc[3, ])

new_row_series = pd.Series(['n1','n2','n3','n4'])

print(pd.concat([df1, new_row_series])) 
new_row_df = pd.DataFrame([['n1','n2','n3','n4']], columns=['A','B','C','D'])

print(pd.concat([df1, new_row_df]))
print(df1.append(new_row_df)) 
data_dict = {'A' : 'n1', 'B' : 'n2', 'C' : 'n3', 'D' : 'n4'}
print(df1.append(data_dict, ignore_index=True))

row_concat_i = pd.concat([df1, df2, df3], ignore_index=True)
print(row_concat_i) 
# 열방향으로 데이터 연결
col_concat = pd.concat([df1, df2, df3], axis=1)
print(col_concat)
print(col_concat['A'])

# 열추가
col_concat['new_col_list'] = ['n1','n2','n3','n4']

print(pd.concat([df1, df2, df3], axis=1, ignore_index=True))

# 열이름 지정
df1.columns = ['A','B','C','D']
df2.columns = ['E','F','G','H']
df3.columns = ['A','C','F','H']

print(pd.concat([df1, df2, df3], join='inner'))
print(pd.concat([df1, df3], ignore_index=False, join='inner')) 

+ Recent posts