I got the following dataframe
+---+--------------------------------------+
| id| score|
+---+--------------------------------------+
| 1|(math, 90)(physics, 87)(chemistry, 82)|
+---+--------------------------------------+
| 2| (computer, 84)|
+---+--------------------------------------+
| 3| null|
+---+--------------------------------------+
in which column score
is of type str
.
I want to convert this str
into array<str>
like below
+---+--------------------------------------------+
| id| score|
+---+--------------------------------------------+
| 1|['math, 90', 'physics, 87', 'chemistry, 82']|
+---+--------------------------------------------+
| 2| ['computer, 84']|
+---+--------------------------------------------+
| 3| null|
+---+--------------------------------------------+
So basically it splits the string to an array and removes all the parenthesis.
I'm referencing this question but I'm not so sure what's the correct regular-expression to use.
Thanks and appreciate for any help.