Generation

generate functionThu, 16 Feb 2023

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

import pandas as pd import re s = pd.Series(['10','78','54','GOOD','64','23']) def find_non_numbers(s): return s[~s.str.replace('\d+', '').str.contains('\d')] find_non_numbers(s)

Questions about programming?Chat with your personal AI assistant