I have a sample dataframe
df = pd.DataFrame({'foo': [1, 2, 3], 'bar': ['A', 'B', 'C']})
and a series
pd.Series([3, 4, 5, 6], name='buzz')
I want to combine them, so each series row is replicated for each df
row
so the resulting dataframe is equivalent to this
pd.DataFrame({
'foo': [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
'bar': ['A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C', 'A', 'B', 'C'],
'buzz': [3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]
})
I cannot use df.merge
with outer join because these two do not have common columns.
It is pretty easy to do with regular python but I was wondering if there is a better pandas solution.