删除DataFrame中特定条件的行/列
在《Python进行数据分析与挖掘实战》一书中,第10章
删除热水器不工作的数据(水流量为0并且开关机状态为“关”的数据。)
import pandas as pd
data=pd.read_excel('E:\siren\Python dataAnalyst\chapter10\demo\data\original_data.xls',sheetname='原始数据') data=data.drop(['有无水流','热水器编号','节能模式'],axis=1) #删除掉开关机状态为“关”且水流量为0的数据,说明热水器不处于工作状态
data=data[~(data['开关机状态'].isin(['关']) & data['水流量'].isin([0]))]
删除特定的列数据
df.drop('column_name',axis=0,inplace=True)
#或者
del df['column_name']
删除DataFrame中特定条件的行/列的更多相关文章
- 【Matlab开发】matlab删除数组中符合条件的元素与散点图绘制
[Matlab开发]matlab删除数组中符合条件的元素与散点图绘制 声明:引用请注明出处http://blog.csdn.net/lg1259156776/ matlab删除数组中符合条件的元素 如 ...
- pandas删除DataFrame中任意字段等于'null'字符串的行
删除df中任意字段等于'null'字符串的行: df=df.astype(str)#把df所有元素转为str类型 df=df[df['A'].isin(['null','NULL'])] #找出df的 ...
- iOS 删除NSString中特定字符
+(NSString *) stringDeleteString:(NSString *)str { NSMutableString *str1 = [NSMutableString stringWi ...
- C#中删除集合中符合条件的元素以及需注意属相
如果用foreach,会造成被遍历的集合更改后带来异常问题. 此时,用for循环可有效的解决这个问题. for(int i=0;i<List.Count;i++) { if(条件是真) { Li ...
- C++删除字符串中特定的字符
原文:https://snipt.net/aolin/c-6/ //处理string类型的方法del_sp(string &str)待测试 //处理C-Style的方法可用,可以考虑将该方法改 ...
- mongodb morphia删除数组中指定条件的数据
先看mongodb操作: db.test.update({"msgid":170},{"$pull":{"msg":{"comti ...
- PHP删除数组中特定元素
方法一: <?php $arr1 = array(1,3, 5,7,8); $key = array_search(3, $arr1); if ($key !== false) array_sp ...
- **PHP删除数组中特定元素的两种方法array_splice()和unset()
方法一: 复制代码代码如下: <?php$arr1 = array(1,3, 5,7,8);$key = array_search(3, $arr1); if ($key !== false) ...
- 筛选出dataframe中全为数字的列的值
In [1]: import pandas as pd In [2]: import numpy as np In [3]: students = [ ('jack', 'Apples' , 34) ...
随机推荐
- elasticsearch Mapping 定义索引
Mapping is the process of defining how a document should be mapped to the Search Engine, including i ...
- change all column to char
http://bluefrog-oracle.blogspot.com/2011/09/script-submitted-to-otn-to-altter.html Script to Alter v ...
- 【归纳】springboot中的IOC注解:注册bean和使用bean
目前了解的springboot中IOC注解主要分为两类: 1. 注册bean:@Component和@Repository.@Service.@Controller .@Configuration 共 ...
- C语言小笔记(1)
枚举类型的大小是4,和一个int整形大小一样 就是最后一个逗号后面的表达式的值,比如: int a=1,b; b=(a+1,a+2,a+3); 那么b的值就是a+3,也就是4 函数名 :print ...
- 【leetcode】982. Triples with Bitwise AND Equal To Zero
题目如下: Given an array of integers A, find the number of triples of indices (i, j, k) such that: 0 < ...
- jsp中$使用不了
导入了jstl <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>为啥 ...
- MariaDB 创建表
在本章中,我们将学习如何创建表. 在创建表之前,首先确定其名称,字段名称和字段定义. 以下是表创建的一般语法: CREATE TABLE table_name (column_name column_ ...
- beautifhulsoup4的使用
Beautiful: - 基本使用 from bs4 import BeautifulSoup - 解析器: lxml, html.parser soup = Beautiful ...
- UNP学习 非阻塞I/O
缺省状态下,套接口时阻塞方式的.这意味着当一个套接口调用不能立即完成时,进程进入睡眠状态,等待操作完成.我们将可能阻塞的套接口调用分成四种. 1.输入操作:read.readv.recv.recvfr ...
- PCB一些设置记录
开始时设置原点,编辑>>原点>>设置 画PCB时,导入后,根据各个模块放好位置 设计>>类>>添加电源类 设计>>规则>>Cle ...