Converting python time stamp to day of year
<p>How can I convert a python timestamp into day of year:</p>

<pre><code>Timestamp('2015-06-01 00:00:00')
</code></pre>

<p>I want a number where Jan 1 is 1, Jan 2 is 2... Dec 31 is 365 (for a non-leap year)</p>

<p>You might want to take a look at the function <a href="https://docs.python.org/2/library/datetime.html#datetime.datetime.timetuple" rel="nofollow"><code>datetime.timetuple()</code></a> which returns a <a href="https://docs.python.org/2/library/time.html#time.struct_time" rel="nofollow"><code>time.struct_time</code></a> object with your desired attribute. I has a named tuple interface, so you can access the values by index or attribute name.</p>

<pre><code>import datetime

date = datetime.datetime.strptime("2015-06-01 00:00:00",
                                  "%Y-%m-%d %H:%M:%S")
print date.timetuple().tm_yday
#=&gt; 152
</code></pre>

python datetime