Convert DateTime to sequential day of the year
<p>I have a dataframe that contains a series of dates, e.g.:</p>

<pre><code>0    2014-06-17
1    2014-05-05
2    2014-01-07
3    2014-06-29
4    2014-03-15
5    2014-06-06
7    2014-01-29
</code></pre>

<p>Now, I need a way to convert these dates to the sequential day of the year, e.g.</p>

<pre><code>0    168
1    125
2    7
3    180
4    74
5    157
7    29
</code></pre>

<p>All the values are within the same year.
The opposite problem has been asked many times - converting the sequential day of the year to a date, but I need to do the opposite. Is there an easy way to do this with Pandas? Thanks!</p>

<p>EDIT: Answered by piRSquared. Thank you!</p>

<p><strong><em>Option 1</em></strong><br>
<a href="http://pandas.pydata.org/pandas-docs/stable/timeseries.html#time-date-components" rel="nofollow"><strong><em>time-date-components</em></strong></a><br>
Link from @root<br>
Use <code>dt.dayofyear</code></p>

<pre><code>df.iloc[:, 0].dt.dayofyear

0    168
1    125
2      7
3    180
4     74
5    157
7     29
Name: 1, dtype: int64
</code></pre>

<hr>

<p><strong><em>Option 2</em></strong><br>
<a href="http://strftime.org/" rel="nofollow"><strong><em>strftime.org</em></strong></a><br>
Use <code>dt.strftime('%-j')</code></p>

<pre><code>df.iloc[:, 0].dt.strftime('%-j')


0    168
1    125
2      7
3    180
4     74
5    157
7     29
Name: 1, dtype: object
</code></pre>

python pandas