Search code examples
pythonpandasdataframedrop

Can't drop a certain row in Pandas


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.


Solution

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

    solved the problem.