pandas remove seconds from datetime index
<p>I have a pandas dataFrame called 'df' as follows</p>

<pre><code>                       value    
2015-09-27 03:58:30    1.0  
2015-09-27 03:59:30    1.0  
2015-09-27 04:00:30    1.0  
2015-09-27 04:01:30    1.0
</code></pre>

<p>I just want to strip out the seconds to get this</p>

<pre><code>                       value    
2015-09-27 03:58:00    1.0  
2015-09-27 03:59:00    1.0  
2015-09-27 04:00:00    1.0  
2015-09-27 04:01:00    1.0
</code></pre>

<p>How can i do this?</p>

<p>ive tried things like</p>

<pre><code>df.index.to_series().apply(datetime.replace(second=0, microsecond=0))
</code></pre>

<p>but i always get errors </p>

<pre><code>TypeError: descriptor 'replace' of 'datetime.datetime' object needs an argument
</code></pre>

<p>You could use <a href="https://docs.python.org/2/library/datetime.html#datetime.datetime.replace" rel="nofollow"><code>datetime.replace</code></a> to alter the second's attribute as shown:</p>

<pre><code>df.index = df.index.map(lambda x: x.replace(second=0))
</code></pre>

<p><a href="http://i.stack.imgur.com/xO9gu.png" rel="nofollow"><img src="http://i.stack.imgur.com/xO9gu.png" alt="Image"></a></p>

python pandas indexing seconds