I didn't really know how to give a good descriptive title, but here's my question. Let's consider a DataFrame df:
col_name
0 Category1
1 item1()
2 item2()
3 Category2
4 item3()
5 item4()
6 item5()
I need to get this:
categories items
0 Category1 item1
1 Category1 item2
2 Category2 item3
3 Category2 item4
4 Category2 item5
But categories could be continents and items could be countries.
I know that all the items have () with an expression inside, so I can easily provide a boolean mask and then create a list of categories with:
msk = df[~df['col_name'].str.contains('[^A-Za-z\s]')]['col_name'].tolist()
But now, now I'm stuck. Could you please give me any piece of advice?