对数据联合、连接以及重排列有用的工具。
分层索引
分层索引是 Pandas 的重要特性,允许你在一个轴向上拥有多个(两个或两个以上)索引层级。
分层索引在重塑数据和数组透视表等分组操作中扮演了重要角色。
swaplevel
sort_index
sum
groupby
set_index
reset_index
联合与合并数据集
merge
concat
combine_first
join
concatenate
concat
TypeError: concat() got an unexpected keyword argument 'join_axes'
where
重塑和透视
重排列表格型数据的多种基础操作被称为重塑或透视。
stack
unstack
pivot
pivot
方法等价于使用set_index
创建分层索引,然后调用unstack
。
在DataFrame中,pivot
方法的反操作是pandas.mel
t。与将一列变换为新的Data Frame中的多列不同,它将多列合并成一列,产生一个新的DataFrame,其长度比输入更长。