I wonder, if there is a less clumsy way to create all combinations for all weeks for the following example:
df = pd.DataFrame({
'Gender': ['female', 'female', 'female', 'female'],
'Bla': ['a', 'a', 'a', 'a'],
'Week': [1, 2, 3, 4]
})
print(df)
number_of_weeks = 52
temp = df[['Gender', 'Bla']].drop_duplicates()
results = temp.loc[temp.index.repeat(number_of_weeks)]
results["Week"] = range(1, len(results) + 1, 1)
print(results)
This kind of work but it also should work for situations with more than 1 "level" for a categorical variable.
df = pd.DataFrame({
'Gender': ['female', 'female', 'female', 'female'],
'Bla': ['a', 'b', 'a', 'a'],
'Week': [1, 2, 3, 4]
})
The above code would expand this to infeasible week numbers.