Answers for "pandas string manipulation on column"

0

pandas string manipulation on column

In [21]:

def func(string):
    a_new_string =string.replace('- ','_')
    a_new_string1 =a_new_string.replace('-','_')
    a_new_string2= a_new_string1.rstrip(' months')
    return a_new_string2

df['Time'] = df['Time'].apply(func)
df
Out[21]:
    Time
0    2_3
1    1_2
2  10_11
3    4_5
Posted by: Guest on July-12-2020

Code answers related to "pandas string manipulation on column"

Python Answers by Framework

Browse Popular Code Answers by Language