Home > Blockchain >  Pandas remove numeric rows/values from column
Pandas remove numeric rows/values from column

Time:02-03

How can i remove the rows where a column "Name" contains numeric values.

below is the input df,

data = [['tom', 10], ['nick', 15], ['juli', 14],['00012', 14],['abc123', 14]]

Expected result is,

    Name    Age
0   tom     10
1   nick    15
2   juli    14

CodePudding user response:

df[~df.Name.str.contains(r'\d')]

CodePudding user response:

Try this:

df = df[df.Name.str.isalpha()]

str.isalpha() checks if all characters in the string are alphabetic, if not return False

  • Related