append pandas series in loop
<p>I have tries using pandas.Series().append() inside a loop but the return is the same Series that went into this method. I need this method to return a pandas Series with repeating values. The number of repetitions decided by num.</p>

<pre><code>def expand(ser, num):
sers = ser
x = 0
while(x &lt; num):
    sers.append(sers).reset_index(drop=True)
    x+=1
return sers
</code></pre>

<p>Is there a reason you don't want to use <a href="http://pandas.pydata.org/pandas-docs/version/0.17.1/generated/pandas.Series.repeat.html" rel="nofollow"><code>pandas.Series.repeat</code></a>?</p>

<pre><code>import pandas as pd
import numpy as np

s = pd.Series(np.random.randn(3), index=['a', 'b', 'c'])

num = 3

repeated_s = s.repeat(num)
repeated_s

a    1.445775
a    1.445775
a    1.445775
b   -1.672416
b   -1.672416
b   -1.672416
c    1.551762
c    1.551762
c    1.551762
dtype: float64
</code></pre>

python pandas