Answers for "split strings around given separator/delimiter"

0

Split the string using the separator

# Split the string using the separator

text= "Orange,Apple,Grapes,WaterMelon,Kiwi"
print(text.split(','))
Posted by: Guest on December-08-2021
0

split strings around given separator/delimiter

# split strings around given separator/delimiter
# import Pandas as pd 
import pandas as pd 
   
# create a new data frame 
df = pd.DataFrame({'Location': ['Cupertino,California', 'Los Angles, California', 'Palo Alto, California']
                   }) 
   
df[['City','State']] = df.Location.str.split(',',expand=True) 
df
print(df)
Posted by: Guest on March-25-2022

Python Answers by Framework

Browse Popular Code Answers by Language