Generation

generate functionMon, 20 Feb 2023

Write a function that finds all non-numeric rows in the 'Reviews' column of dataframe 'df1' using regex

def is_numeric(s): return bool(re.search(r'^(\d+)$', s)) df1 = pd.DataFrame({"Reviews": ["1", "2", "3", "4", "5", "apple", "orange"]}) df1[~df1["Reviews"].apply(is_numeric)]

Questions about programming?Chat with your personal AI assistant