Stack Exchange
Trying to remove all rows without a numeric value in a column using python pandas
       age    
0       55
1       45
2       58
4      N/A

i need to remove all the rows that doesn't contain numeric values in column age above given dataframe example
Expected output is given bellow
       age
0       55
1       45
2       58


Try this
import pandas as pd
import numpy as np
data = {
"age": [0, 55, 1,55,4,'N/A',5]

}
df = pd.DataFrame(data)
df=df[df['age'].apply(lambda x: type(x) in [int, np.int64, 
float, np.float64])]

print(df) 


some what helpfull

import pandas as pd
import numpy as np
data={"Name":["jhon","alex","lisa","maya"],"age":[10,14,np.nan,15]}
df=pd.DataFrame(data)
df.dropna()
Hope it was some help to you. dropna() method drop the rows with na value

Use pd.numeric as boolean mask:
df = df.loc[pd.to_numeric(df['age'], errors='coerce').notna()]
print(df)

# Output
  age
0  55
1  45
2  58

All non numeric values will be converted as NaN.

The shortest solution is to use _convert(numeric=True):
df['age'] = df['age']._convert(numeric=True)
df.dropna(inplace=True)

