Delete rows with arbitrary values in pandas DataFrame

Premise

For a column with a data frame (here id column), I had to remove all the rows that contained a particular value. I tried to get the line number and various methods, but I made a note because there was an easy way to handle it.

code

import pandas as pd
data = pd.read_csv("Original data path") 

list = [1,2,3]   ###Any value you want to erase

for i in list:
   data = data[data['id'] != i]

That's all there is to it.

Recommended Posts

Delete rows with arbitrary values in pandas DataFrame
Remove rows with duplicate indexes in pandas DataFrame
Replace column names / values with pandas dataframe
Handle integer types with missing values in Pandas
Bulk Insert Pandas DataFrame with psycopg2
Load csv with duplicate columns in pandas
Get the top nth values in Pandas
Search / Delete Missing Values in "Kaggle Memorandum"
How to reassign index in pandas dataframe
[Python] Add total rows to Pandas DataFrame
Fill in missing values with Scikit-learn impute
Working with 3D data structures in pandas
Is there NaN in the pandas DataFrame?
Convenient time series aggregation with TimeGrouper in pandas
Delete data in a pattern with Redis Cluster
A story packed with absolute values in numpy.ndarray
Save Pandas DataFrame as .csv.gz in Amazon S3
Aggregate VIP values of Smash Bros. with Pandas
Add totals to rows and columns in pandas
Find the sum of unique values with pandas crosstab
Check if the expected column exists in Pandas DataFrame
Extract N samples for each group with Pandas DataFrame
Convert comma-separated numeric strings to numbers in Pandas DataFrame
How to access with cache when reading_json in pandas
Fill outliers with NaN based on quartiles in Pandas
How to extract null values and non-null values with pandas
Convert numeric variables to categorical with thresholds in pandas
How to find out if there is an arbitrary value in "somewhere" of pandas DataFrame
[python] Use DataFrame to label arbitrary variables and arrays together and save them in csv [pandas]