Home > Blockchain >  deleting pandas dataframe rows not working
deleting pandas dataframe rows not working

Time:08-07

import numpy as np
import pandas as pd
randArr = np.random.randint(0,100,20).reshape(5,4)
df =pd.DataFrame(randArr,np.arange(101,106,1),['PDS', 'Algo','SE','INS'])
df.drop('103',inplace=True)

this code not working

Traceback (most recent call last):
  File "D:\Education\4th year\1st sem\Machine Learning Lab\1st Lab\python\pandas\pdDataFrame.py", line 25, in <module>
    df.drop('103',inplace=True)

CodePudding user response:

The string '103' isnt in the index, but the integer 103 is:

Replace df.drop('103',inplace=True) with df.drop(103,inplace=True)

  • Related