How can I get a list of the days in a year and follow this form?
<p>This code not work at all, and I'm still confusing with the pandas datetime method...</p>

<pre><code>def date_list():

    list = []

    for i in pd.date_range(datetime(2016, 1, 1), datetime(2016, 12, 31)):

        list.append(datetime[1], datetime[2])
    return list
</code></pre>

<p>This is the example for the list, and should I use zfill method for making this list?(If it's leap year)
  [0101, 0102, 0103, ..., 1230, 1231]</p>

<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DatetimeIndex.strftime.html" rel="nofollow"><code>strftime</code></a> to directly do the formatting:</p>

<pre><code>dt_list = pd.date_range('2016-01-01', '2016-12-31').strftime('%m%d')
</code></pre>

<p>Use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tolist.html" rel="nofollow"><code>tolist</code></a> if you want a Python list instead of a numpy array:</p>

<pre><code>dt_list = pd.date_range('2016-01-01', '2016-12-31').strftime('%m%d').tolist()
</code></pre>

python python-3.x pandas anaconda miniconda