读取 pandas 数据框时跳过包含特定值的特定行 [英] skip specific line that contains certain value when you read pandas data frame

查看:67
本文介绍了读取 pandas 数据框时跳过包含特定值的特定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用命令pd.read_csv读取csv时,
如何跳过一行中包含特定值的行?
如果在第50行,第55行中,第1列的值为100,那么当我读取csv文件时,我想跳过这些行。
如何将这些命令放入诸如pd.read_csv(’read.csv’)之类的读入命令中?
的总长度为300。

When you read the csv using command pd.read_csv, How do I skip the line that contains specific value in a row? If in 50th, 55th row, the 1st column has the value, 100, so I want to skip those lines when I read the csv file. How I can put those command in a read-in command like pd.read_csv('read.csv')? total length of the value is 300.

推荐答案

稍后删除它们和不读取它们有什么区别?完全没有?您可能只是做:

What is the difference between dropping them later, and not reading them at all? You might simply do:

pd.read_csv('file.csv').query('col1 != 100')

这篇关于读取 pandas 数据框时跳过包含特定值的特定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆