Generation

generate functionThu, 16 Feb 2023

There is a Pandas Series column: 'loan_amnt' 10 78 54 GOOD 64 23 Write a function that replace all rows with letters in the column to NaN. Example: find_non_numbers(df, 'loan_amnt') df Result: 10 78 54 NaN 64 23

def find_non_numbers(df, col): for i in df[col]: if type(i) == str: i = np.nan find_non_numbers(df, 'loan_amnt')

Questions about programming?Chat with your personal AI assistant