-1

I have a dataframe like the one below having 3 types of status -'complete','start' and 'fail'. I want to create another dataframe from this keeping only the "fail" status entries with their corresponding level number.

enter image description here

1 Answers1

1

Let's do this:

fail_df = df[df['status']=='fail']

or this with str.contains:

fail_df = df[df['status'].str.contains(r'fail',case=False)]

Both ways will give a new dataframe with only status being 'fail'. However, the str.contains method is more robust to typo's.

sophocles
  • 13,593
  • 3
  • 14
  • 33