I have a large CSV file that I am trying to delete many rows from.
The column I am making this decision on has many different crops, but I am only interested in a few of the crops and their related data in other columns.
The code I have tried is the following:
import pandas as pd
df = pd.read_csv('C2014.csv')
cropnames = ['Cotton', 'Rice', 'Corn']
for crop in cropnames:
df = df[df.Nomcultivo !] crop]
The strings in cropnames are the string values in the rows I want in the column "Nomcultivo." I hope that makes sense. Any help would be appreciated!