import numpy as np
import pandas as pd
s1 = pd.Series(['a', 'b'])
s2 = pd.Series(['c', 'd'])
# 对series的操作,ignore_index=True是重新排索引
pd.concat([s1, s2], ignore_index=True)
结果
0 a
1 b
2 c
3 d
dtype: object
df1 = pd.DataFrame([['a', 1], ['b', 2]],columns=['letters', 'numbers'])
df2 = pd.DataFrame([['c', 3], ['d', 4]],columns=['letter', 'number'])
# 对dataframe的操作
pd.concat([df1, df2])
# axis=0,join='inner', 按行连接,无交集,无法连接
pd.concat([df1, df2],axis=0,join='inner')
# axis=1,join='inner',按列交集,索引一致。
pd.concat([df1, df2],axis=1,join='inner')
# axis=0,join='outer',按行并集。
pd.concat([df1, df2],axis=0,join='outer')