Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to remove rows from a dataset based on condition?

I've ran the following Python script in the Query Editor but it does not change the dataset.

 

# 'dataset' holds the input data for this script

if dataset.iloc[5,2] == 1:
    dataset.drop(4)

I want the code to delete row 4 if row 5's value column is equal to 1. Any idea if there's a problem with my code? Here is a snippet of the data

 

 

  • # 'dataset' holds the input data for this script
    
    if dataset.iloc[5,2] == 1:
        dataset = dataset.drop(4)

3 Replies

  • # 'dataset' holds the input data for this script
    
    if dataset.iloc[5,2] == 1:
        dataset = dataset.drop(4)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi lbendlin 

       

      Tried this but I only got the following output. Any idea why?