Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas replace word begins with contains

In [71]:
df.loc[df['sport'].str.contains('ball'), 'sport'] = 'ball sport'
df

Out[71]:
    name       sport
0    Bob      tennis
1   Jane  ball sport
2  Alice  ball sport
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #replace #word #begins
ADD COMMENT
Topic
Name
3+4 =