junayed
0
Q:

string list into list pandas

import ast 

# initializing string representation of a list 
ini_list = "[1, 2, 3, 4, 5]"
  
# Converting string to list 
res = ast.literal_eval(ini_list) 
  
# printing final result and its type 
print ("final list", res) 
print (type(res)) 
0
# Python code to convert string to list 
  
def Convert(string): 
    li = list(string.split(" ")) 
    return li 
  
# Driver code     
str1 = "Geeks for Geeks"
print(Convert(str1)) 
0

New to Communities?

Join the community