0

I have a dataframe 'df' that has many columns and one of these columns, 'Name', looks like the below:

Name
Alter0tive Medicine
A0lytics
Big Data A0lytics
Business A0lytics
Can0bis
Career Ma0gement
Chi0 Interne

Now as you can observe, Name columns has string data but these have zero '0' in place of the chatarcters 'na' e.g. instead of Alternative it is Alter0tive and so forth.

I wanted to replace the '0' with 'na' so that I have proper strings.

What I am trying to do is:

df.Name = df.Name.str.contains(r'[0]').replace('0', 'na')

But this resulted in

Name
False
False
False
....
....
....
False

Why my code failed and how can I get the end result which should look like this:

Name
Alternative Medicine
Analytics
Big Data Analytics
Business Analytics
Cannabis
Career Management
China Internet
.....
.....
LeMarque
  • 733
  • 5
  • 21

0 Answers0