So I want to delete some rows based on a condition.
I tried to drop as it is explained in the website.
My dataframe looks like this:
jobs
job_name number
0 job1 163
1 job2 200
2 job3 3
And I have a list:
my_jobs = [job2, job3]
My condition:
for job in jobs['job_name']:
if job not in my_jobs:
jobs_df.drop(job, axis=0)
And I want my dataframe looks like this:
jobs
job_name number
1 job2 200
2 job3 3
However, I'm getting:
keyerror:"['jo1'] not found in axis"
What am I doing wrong?
jobs_df = jobs_df[jobs_df['job_name'].isin(my_jobs)].