Pandas的常用函数
前言
Pandas有一些常用方法, 可以作为回调函数用于其它函数.
pandas.DataFrame.reindex
reindex方法用于把DataFrame按新的索引转化, 同时可选填充空值或者其他方法(如ffill, 按前项填充). 默认情况下, 重新索引过的DataFrame会复制原来DataFrame, 除非索引没有变或者设置copy=False.
1  | frame5 = pd.DataFrame(np.arange(9).reshape((3,3)), index=['a','b','c'], columns=['Ohio','Texas','California'])  | 
丢弃某些行或列
对于DataFrame, 想要删除某行或列是很方便的, 直接通过drop([])方法可以实现, 默认删除行, 如果需要删除列, 可以设置参数axis=1.
1  | frame5  | 
- Title: Pandas的常用函数
 - Author: Kopei
 - Created at : 2018-09-17 00:00:00
 - Updated at : 2025-08-13 18:15:58
 - Link: https://kopei.github.io/2018/09/16/python-2018-09-17-pandas-common-methods/
 - License: This work is licensed under CC BY-NC-SA 4.0.
 
        Comments