Yes, there is the split function, however before calling it on your string, you must get rid of the [ and ], or else instead of ['1', '2', '3', '4']
, you will get ['[1', '2', '3', '4]']
, so instead of s.split()
, we do s[1:-1].split()
, also this means your list is strings instead of ints ('1'
instead of 1
), but that is easily fixable:
[int(i) for i in s[1:-1].split()]
1
solved Any built-in function in pandas/python which converts a list like data into a list