Generation

generate functionThu, 16 Feb 2023

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

df[df['loan_amnt'].str.contains('[a-z]', flags=re.IGNORECASE, regex=True)]

Questions about programming?Chat with your personal AI assistant