Identifying non-numeric values in a DataFrame column containing numerics
1
2
3
df.loc[
df ["col_name"].dropna().astype(str).str.contains(r'[a-z]')
]["col_name "].unique()
dropna()
is needed where the column contains NaN
s, to fend off an error.
astype()
is needed to force numerics to be treated as strings.
This post is licensed under CC BY 4.0 by the author.