Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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
Comment

PREVIOUS NEXT
Code Example
Python :: python replace double quotes with single quotes in string json loads 
Python :: python how to get the folder name of a file 
Python :: how to generate random numbers in python 
Python :: how to create 3 dimensional array in numpy 
Python :: streamlit button 
Python :: whatsapp online tracker python script 
Python :: kivymd window size 
Python :: how to hide tensorflow warnings 
Python :: get the last element from the list 
Python :: how to get input from user in python with out press enter 
Python :: twitter api v2 python tweepy 
Python :: pandas dataframe filter 
Python :: pandas df num rows 
Python :: import database in python using sqlalchemy 
Python :: make zipfile from directory py 
Python :: pyserial read 
Python :: how to get time in python 
Python :: python replace nth occurrence in string 
Python :: sqlite3 python 
Python :: how to use get-pip.py 
Python :: telethon send image 
Python :: python partial 
Python :: python - subset dataframe based on unique value of a clumn 
Python :: To visualize the correlation between any two columns | scatter plot graph 
Python :: catalan number 
Python :: Calculate Euclidean Distance in Python 
Python :: Python NumPy split Function Example 
Python :: how to sum all the numbers in a list in python 
Python :: opencv google colab 
Python :: algorithms for Determine the sum of al digits of n 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =