Question:
I have a DataFrame that looks somewhat like this:
I want to remove the braces/curly brackets and explode each of the elements into its own row. So it would look something like this in the end:
I have tried to first eliminate the curly brackets with
then expand/explode the elements with
I have tried more ways to fix the latter part. However, I think even if it works, the code still does a very inefficient job as it takes a bit long (~ 2mins) on my dataset of around 10k rows. Is there a better approach to this?
Answer:
You can just use a combination of
apply
and
explode
functions:
EDIT: Figured out the
explode
has an
ignore_index
keyword that can be useful in this case.
If you have better answer, please add a comment about this, thank you!