tradebigshort
tradebigshort

Reputation: 39

delete numeric numbers in all columns python

I want delete all numeric number in columns ,

Exemple :

  1. ABC *12547 NDFRE12 -> ABC * NDFRE
  2. 12aRE 15P -> aRE P

I want a code with python. I talk about all columns and not only one row.

Using Excel file .xlsx

Column A for example

Upvotes: 1

Views: 56

Answers (2)

wasif
wasif

Reputation: 15478

Try this for entire dataframe:

df = df.replace(to_replace=r'\d+', value='', regex=True)

For only one column:

df['COLUMN'] = df['COLUMN'].str.replace('\d+', '')

Upvotes: 2

BENY
BENY

Reputation: 323226

Try with replace

l=['ABC *12547 NDFRE12',
'12aRE 15P -> aRE P']
s = pd.Series(l)
0    ABC *12547 NDFRE12
1    12aRE 15P -> aRE P
s = s.str.replace('\d+','')
0       ABC * NDFRE
1    aRE P -> aRE P
dtype: object

Upvotes: 1

Related Questions