Hi I am new and trying to learn Python and Pandas. I have come across solutions online to explode DF without '{' and '|' separators. But I have not been able to find a solution specific to mine and was hoping for some help.
I have a DataFrame that looks like this:
Name gender message_type code
1 M orange 103
2 F {102|777}
3 M {red|blue} 983
I want to explode the table so that each element of the array becomes its separate row
Like this
Name gender message_type code
1 M orange 103
2 F 102
2 F 777
3 M red 983
3 M blue 983
So far I have tried writing something like this to test on one column, but to no avail
df_exploded = df1['code'].apply(lambda x:[v.split('|') for v in x]).apply(pd.Series.explode)
Any help on this would be appreciated. Thank you