pd.concat(objs, axis=0, join=’outer’, join_axes=None, ignore_index=False, keys=None, levels=None, names=None, verify_integrity=False, copy=True)
参数说明:
objs:连接对象,多以列表、字典传入
axis:轴向,0代表纵向连接,1,代表横向连接
join:连接方式,共有’inner’,’left’,right’,’outer’
join_axes:参与连接的索引
ignore_index:是否忽略索引
keys:层次化索引
横向连接
import pandas as pd
s1=pd.Series([1,2,3],index=list('abc'))
s2=pd.Series([3,4,5],index=list('bde'))
pd.concat([s1,s2])
Out[6]:
a 1
b 2
c 3
b 3
d 4
e 5
dtype: int64
纵向连接
pd.concat([s1,s2],axis=1)
__main__:1: FutureWarning: Sorting because non-concatenation axis is not aligned. A future version
of pandas will change to not sort by default.
To accept the future behavior, pass 'sort=False'.
To retain the current behavior and silence the warning, pass 'sort=True'.
Out[7]:
0 1
a 1.0 NaN
b 2.0 3.0
c 3.0 NaN
d NaN 4.0
e NaN 5.0
三个资料Q群下载不了也转发不了,先放这里Fine_tuning.zipLangChain.zipdata_clear.rar