I want to create a df starting from this data
item_features = {'A': {1, 2, 3}, 'B':{7, 2, 1}, 'C':{3, 2}, 'D':{9, 11} }
pos = {'B', 'C'}
neg = {'A'}
I want to obtain the following dataset:
1 2 3 7 positive item_id
0 1 1 0 1 1 B
1 0 1 1 0 1 C
2 1 1 1 0 0 A
So i want that the df:
-have the df columns always ordered by their Number during the
creating process ? Like in this case it is 1 -2 - 3- 4 and i want
to be sure that i never have an order like 4-1-3-2
- contains only item_id that are in one of the 2 sets ( pos or neg).
- if the item is positive the corresponding 'positive' column will be set to 1 else 0
- the other columns_names are the value in the item_features dictionary, but only for the items that are either in pos or in neg.
- the value in the column must be 1 if the corresponding column name is in value of the item_features dict for that specific item.
What is an efficient way to do that ?