Answers for "how to deal with string data in column pandas"

0

in dataframe particular column to string

df["fruit"] = df["fruit"].astype("|S")
Posted by: Guest on February-01-2021
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 "how to deal with string data in column pandas"

Python Answers by Framework

Browse Popular Code Answers by Language