How to get the difference between two 24 hour times?
<p>Is there a simple way in pandas to tell the difference between 24 hour times as follows:</p>

<pre><code>9:45 17:10
</code></pre>

<p>The difference is 7 hours and 25 minutes which is 445 minutes.</p>

<p>Sure:</p>

<pre><code>&gt;&gt;&gt; from pandas import Timestamp
&gt;&gt;&gt; Timestamp('9:45')    
Timestamp('2016-09-30 09:45:00')
&gt;&gt;&gt; Timestamp('17:10')
Timestamp('2016-09-30 17:10:00')
&gt;&gt;&gt; Timestamp('17:10') - Timestamp('9:45')
Timedelta('0 days 07:25:00')
&gt;&gt;&gt; td = Timestamp('17:10') - Timestamp('9:45')
&gt;&gt;&gt; td
Timedelta('0 days 07:25:00')
</code></pre>

<p>And if you really need the time in minutes:</p>

<pre><code>&gt;&gt;&gt; td.seconds/60
445
&gt;&gt;&gt;
</code></pre>

<h2> Edit </h2>

<p>Just double-checked the documentation, and the <code>seconds</code> attribute of a Timedelta object returns: <code>Number of seconds (&gt;= 0 and less than 1 day)</code>.</p>

<p>So, to really be safe if you want the minutes, use:</p>

<pre><code>&gt;&gt;&gt; td.delta # returns the number of nanoseconds   
26700000000000
&gt;&gt;&gt; td.delta * 1e-9 / 60
445.0
</code></pre>

python pandas