I have a DataFrame (test_df) that looks like,
Year Month TAGS
2019 5 A, B
2019 5 A, C
2019 5 A
2019 5
2019 5 B, C, D
2019 5 C, E
I would like to get a Tags LIST that looks like this stacked up vertically when I split the tags string by comma.
A
B
A
C
A
B
C
D
C
E
I utilized 2 For loops in order to get the list of tags
check=[]
for j in range(len(test_df)):
for i in range(len(test_df['TAGS'][j].split(', '))):
check.append(test_df['TAGS'][j].split(', ')[i])
Is there a better way to get the TAGS list without the use of 2 For loops.