Consider:
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 the dataframe example.
The expected output is given below
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)