I am trying to build a binary matrix, where the rows are groups and columns are items that could be in the groups. There is a 1 in the column if the item is present and a 0 if not. Is there a way to do this efficiently?
For example, if I have a dictionary like this:
{device1 : (news1, news2, ...), device2 : (news 2, news 4, ...)...}
Is there a quick way to turn it into a matrix where device1, device2, etc are rows and news1, news2, etc. are columns with 1s or 0s?
I have tried iterating over columns, but its inefficient and I think there is an easier way to do it!