I have sets of strings, from which I need to construst the main indicator variable columns in a DataFrame. Is there a way to do this dimension expansion in Python pandas?
E.g. if I have these two sets:
los = set(["abc", "def"])
his = set(["X", "Y", "Z"])
I want to get as a result a DataFrame that includes all the combinations of the sets. Like this:
import pandas as pd
df = pd.DataFrame({"los": ["abc", "abc", "abc", "def", "def", "def"], "his": ["X", "Y", "Z", "X", "Y", "Z"]})
Ideally, I'd like this to be easily generalizable to an arbitrary number of sets.