-2

I have a DataFrame "df" with three columns named: "Particle", "Frequency1", "Frequency2" and a lot of rows.

I want to delete the rows where Frequency1 and Frequency2 are simoustaneously equal to 0.

What is the sintax for doing this?

Laura
  • 1,192
  • 2
  • 18
  • 36

1 Answers1

2

You can also use: df = (df[df.Frequency1 == 0] & df[df.Frequency2 == 0]).

This will delete the row which has 0 in both columns of 'Frequency1andFrequency2`.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
  • Thank you @Jeru . It works perfectly – Laura Jul 04 '17 at 13:50
  • @Laura You can also use: `df[['Frequency1', 'Frequency2']].corr()`. And if the resulting matrix has any values with 1, you can delete the corresponding row. But always use this *only if* the values in `Frequency1` and `Frequency2` are equal to 0. They must not be equal to each other. This is another more complicated way of doing it. Just thought of sharing it !!! – Jeru Luke Jul 04 '17 at 14:01