str.isdigit checks the content of every string in a pandas Series through the .str accessor. It returns a same-length Boolean Series: True only when an element contains digit characters exclusively; empty strings, signs, and decimal points produce False. section 9.0 section 5.6
Filter values that contain only digits
Given s = Series('this is a test 123 456'.split()), run s.str.isdigit() to produce Boolean results, then use s.loc[s.str.isdigit()] to keep only 123 and 456. The Boolean Series shares s's index, so it works directly as a mask. section 9.0
Clean an age column
After removing missing ages, use df = df[df['age'].str.isdigit()] to discard rows whose age text cannot become an integer. This is suitable for ordinary ages, but it is not a general numeric test: values such as -2 or 3.5 fail. section 5.6
For broader numeric conversion, pd.to_numeric(..., errors='coerce') can replace this preliminary check by converting valid values and turning unconvertible values into NaN. Either approach still requires checking implausible results, such as an age of 9,394. section 5.6
s.str.isdigit()
Inspect the concise Series expression that applies isdigit elementwise. section 9.0

