There is a Pandas Series column: 'loan_amnt' 10 78 54 GOOD 64 23 Write a function that finds all rows with letters in the column and replace them with NaN. Example: find_non_numbers(df, 'loan_amnt') df Result: 10 78 54 NaN 64 23
def find_non_numbers(data, column): return data[~pd.to_numeric(data[column], errors='coerce').notnull()] #OR import re def find_non_numbers(data, column): return data[~data[column].map(lambda x: bool(re.search(r'[a-zA-Z]', x)))]