Question: In Pandas I have a series and a multi-index:

```
s = pd.Series([1,2,3,4], index=['w', 'x', 'y', 'z'])
idx = pd.MultiIndex.from_product([['a', 'b'], ['c', 'd']])

```

What is the best way for me to create a DataFrame that has idx as index, and s as value for each row, preserving the index in S as columns?

```
df =
       w   x   y   z
a  c   1   2   3   4
   d   1   2   3   4
b  c   1   2   3   4
   d   1   2   3   4

```

Answer: 
Use the `pd.DataFrame` constructor followed by `assign`

```
pd.DataFrame(index=idx).assign(**s)

     w  x  y  z
a c  1  2  3  4
  d  1  2  3  4
b c  1  2  3  4
  d  1  2  3  4

```
You can use [`numpy.repeat`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.repeat.html) with [`numpy.ndarray.reshape`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.reshape.html) for duplicate data and last `DataFrame` constructor:

```
arr = np.repeat(s.values, len(idx)).reshape(-1, len(idx))
df = pd.DataFrame(arr, index=idx, columns=s.index)
print (df)
     w  x  y  z
a c  1  1  1  1
  d  2  2  2  2
b c  3  3  3  3
  d  4  4  4  4

```

**Timings**:

```
np.random.seed(123)
s = pd.Series(np.random.randint(10, size=1000))
s.index = s.index.astype(str)
idx = pd.MultiIndex.from_product([np.random.randint(10, size=250), ['a','b','c', 'd']])

In [32]: %timeit (pd.DataFrame(np.repeat(s.values, len(idx)).reshape(len(idx), -1), index=idx, columns=s.index))
100 loops, best of 3: 3.94 ms per loop

In [33]: %timeit (pd.DataFrame(index=idx).assign(**s))
1 loop, best of 3: 332 ms per loop

In [34]: %timeit pd.DataFrame([s]*len(idx),idx,s.index)
10 loops, best of 3: 82.9 ms per loop

```