I have a dataframe like as shown below
td = {966: [('Feat1', -0.04),
('Feat2=True ', -0.02),
('Feat3 <= 20000.00', 0.01),
('Feat4=Power Supply', -0.01),
('Feat5=dada', -0.0)],
879: [('Feat8=Rare', 0.02),
('Feat11=HV', -0.01),
('Feat21=Power Supply', -0.01),
('20000.00 < Feat3 <= 50000.00', 0.01),
('Feat5=dada', -0.01)]}
I would like to do the below
a) Split the tuple within dict based on , comma seperator
b) store the numeric part in value column of dataframe and text part in feature column of dataframe
c) repeat the key values for all values in dataframe (and store it in key column)
I tried the below but it is not efficient/elegant and doesn't scale for big data of million rows
feature=[]
value=[]
key=[]
for k, v in td.items():
for x in v:
key.append(k)
f, v = x
feature.append(f)
value.append(v)
data_tuples = list(zip(key,feature,value))
pd.DataFrame(data_tuples, columns=['key','feature','value'])
I expect my output to be like as shown below
