I have a list
like this:
list1=['weather:monday="severe" weather:friday, xxx:sunday="calm" xxx:sunday="high severe", yyy:friday="rainy" yyy:saturday=']
what I want is to result in dataframe like this:
column1 column2 column3
weather Monday severe
weather Friday
xxx Sunday calm
xxx Sunday high severe
yyy Friday rainy
yyy Saturday
First, in the list
, I tried the following:
newlist2 = [word for line in list1 for word in line.split(':')]
newlist2
['weather',
'monday="severe" weather',
'friday, xxx',
'sunday="calm" xxx',
'sunday="high severe", yyy',
'friday="rainy" yyy',
'saturday=']
and
newlist3 = [word for line in newlist2 for word in line.split('=')]
newlist3
['weather',
'monday',
'"severe" weather',
'friday, xxx',
'sunday',
'"calm" xxx',
'sunday',
'"high severe", yyy',
'friday',
'"rainy" yyy',
'saturday',
'']
After that I convert the list into a dataframe
df=pd.Dataframe(newlist3)
However, the outcome is not the desired one.
Any ideas on how to reach my desired outcome?