0

note that title is index.

title rating rat_count
'Til There Was You 2.333333 9
1-900 2.600000 5
101 Dalmatians 2.908257 109
12 Angry Men 4.344000 125
... ... ...
Young Guns 3.207921 101

I tried

i = movies[movies['rating']==3.4444].index
movies.drop(i)
# This one has no effect and didn't removed

2:

movies.drop(0)

3:

movies.drop(movies.iloc[0])

error of 3:

KeyError: '[3.4444444444444446, 9.0] not found in axis'

4:

movies.drop(' ')

error of 4:

KeyError: "[' '] not found in axis"

5:

movies.drop(' ',axis=0)

error of 5:

KeyError: "[' '] not found in axis"

I want to drop the first row, which has no title(or a blank) with 3.44 rating and 9 rat_count.

  • 1
    Please, include a minimal reproducible example. In your case, what is mainly missing is a dataframe (the one you provided is unreadable. And it would be easier for us to help you if you provided it in a python form: ``df = pd.DataFrame([[...]])`` – chrslg Oct 29 '22 at 10:00
  • Please consider updating the question to [a reproducible example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) even though you have solved it. – medium-dimensional Oct 29 '22 at 10:01

1 Answers1

1
movies.drop(movies.index[0])

solved the problem.

  • 1
    Good. It would be nice for future reader that you provide that dataframe example (tho I edited your post to that the dataframe is readable). Besides, I think it's worth mentioning that it is never a good idea to try to match floating point values. Not just with pandas. With computers in general. `==` should almost never be used anywhere near floating point numbers. Because `3.4444 != 3.44439999999999`. And you never know what can make two identical floats to be strictly speaking different (for example `(3.4444*10/10)==3.4444` is False. So, you should match rating with a tolerance. – chrslg Oct 29 '22 at 10:13
  • 1
    For example you could ``df.drop(df[(df.rating-3.4444)**2<0.0001].index)`` – chrslg Oct 29 '22 at 10:17