博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pandas filter数据筛选
阅读量:5248 次
发布时间:2019-06-14

本文共 1158 字,大约阅读时间需要 3 分钟。

 

(博主录制)

 

(官网介绍)

DataFrame.filter(selfitems=Nonelike=Noneregex=Noneaxis=None)

Subset rows or columns of dataframe according to labels in the specified index.

Note that this routine does not filter a dataframe on its contents. The filter is applied to the labels of the index.

Parameters:
items 
list-like

Keep labels from axis which are in items.

like 
string

Keep labels from axis for which “like in label == True”.

regex 
string (regular expression)

Keep labels from axis for which re.search(regex, label) == True.

axis 
int or string axis name

The axis to filter on. By default this is the info axis, ‘index’ for Series, ‘columns’ for DataFrame.

python脚本
# -*- coding: utf-8 -*-"""Created on Sun Sep  8 11:32:40 2019@author: QQ231469242"""import pandas as pdimport numpy as npdf = pd.DataFrame(np.array(([1, 2, 3], [4, 5, 6])),                  index=['mouse', 'rabbit'],                  columns=['one', 'two', 'three'])df.filter(items=['one', 'three'])#select columns by regular expressiondf.filter(regex='e$', axis=1)# select rows containing 'bbi'df.filter(like='bbi', axis=0)

  

 

(博主视频教学主页)

 

转载于:https://www.cnblogs.com/webRobot/p/11485798.html

你可能感兴趣的文章
[置顶] Linux终端中使用上一命令减少键盘输入
查看>>
BootScrap
查看>>
Java实现二分查找
查看>>
UIImage 和 iOS 图片压缩UIImage / UIImageVIew
查看>>
php7 新特性整理
查看>>
RabbitMQ、Redis、Memcache、SQLAlchemy
查看>>
03 线程池
查看>>
手机验证码执行流程
查看>>
设计模式课程 设计模式精讲 2-2 UML类图讲解
查看>>
Silverlight 的菜单控件。(不是 Toolkit的)
查看>>
jquery的contains方法
查看>>
linux后台运行和关闭SSH运行,查看后台任务
查看>>
桥接模式-Bridge(Java实现)
查看>>
303. Range Sum Query - Immutable
查看>>
C# Dynamic通用反序列化Json类型并遍历属性比较
查看>>
前台freemark获取后台的值
查看>>
Leetcode: Unique Binary Search Trees II
查看>>
C++ FFLIB 之FFDB: 使用 Mysql&Sqlite 实现CRUD
查看>>
Spring-hibernate整合
查看>>
c++ map
查看>>