I want to find specific rows in a huge dataframe and assign a comment if the condition is met.
The part of the code I use is as follows:
def check_car(x):
if x['CAR'] == 'FERRARI' and x['COUNTRY'] != 'ITALY':
return 'This is wrong'
else:
x.drop()
After that I use this function to create new data frame with ID and comment.
The new data frame contain IDs with “This is wrong”
as well as None
values.
Instead of that I want to remove all None values from data frame, is it possible to do that in the function itself?
I used x.drop
but I got the error:
ValueError: ("Need to specify at least one of 'labels', 'index' or 'columns'”)