Issue
I have a dataset with many columns. The values in columns start with "[" and end with "]". Like "[Sinopharm]". I want to replace "[" and "]" with nothing. I did the following code but not both can be changed.
data['q3'] = data['q3'].str.replace('[', '')
Important: I want to replace both at once and to all columns. Like 'q4', 'q5' etc
Solution
new_data = data.replace({r'[\[\]]': ''}, regex=True)
Answered By - Timur Shtatland
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.