I have the multilevel dataframe that looks like:
date_time name note value
list index
1 0 2015-05-22 05:37:59 Tom 129 False
1 2015-05-22 05:38:59 Tom 0 True
2 2015-05-22 05:39:59 Tom 0 False
3 2015-05-22 05:40:59 Tom 45 True
2 4 2015-05-22 05:37:59 Kate 129 True
5 2015-05-22 05:41:59 Kate 0 False
5 2015-05-22 05:37:59 Kate 0 True
I want iterate over the list , and for each first row of list check the value of column value, and if it is False, delete this row. So the final goal is to delete all the first rows in list, that have False in value
I use this code, that seems logic:
def delete_first_false():
for list, new_df in df.groupby(level=0):
for index, row in new_df.iterrows():
new_df=new_df.groupby('name').first().loc([new_df['value']!='False'])
return new_df
return df
but I have this error
AttributeError: '_LocIndexer' object has no attribute 'groupby'
could you explain me what's wrong with my method?