MMM MMM - 1 year ago 77
Python Question

skip specific line that contains certain value when you read pandas data frame

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.

Answer Source

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')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download