title: How to get the amount of time with a count of parallel events between two dates
body: <p>I've got the following sort of data with events happening at stations.</p>
  <pre class="lang-py prettyprint-override"><code>   stationId               start                 end
  0          0 2021-03-01 02:00:00 2021-03-01 05:00:00
  1          0 2021-03-01 07:00:00 2021-03-01 08:30:00
  2          0 2021-03-01 04:00:00 2021-03-01 09:30:00
  3          1          ...                  ...
  </code></pre>
  <p>There can be more than one event happening at the same time.</p>
  <p>I want to know the <strong>number of hours</strong> where <strong>n events</strong> happened between <strong>two dates</strong> (like 2021-03-01 00:00:00 to 2021-03-01 10:00:00).</p>
  <p>The <strong>desired result</strong> should look something like this (where count is the number of parallel events and hours representing the number of hours where that many parallel events were active).</p>
  <pre class="lang-py prettyprint-override"><code>   stationId  count  hours
  0          0      0    2.5
  1          0      1    5.0
  2          0      2    2.5
  3          1    ...    ...
  </code></pre>
  <p>Because this is quite hard to understand in plain-text, this image may help in order to understand what I want to achieve.</p>
  <p>Visual representation of the algorithm:-</p>
  <p><a href="https://i.stack.imgur.com/1osdh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1osdh.png" alt="enter image description here" /></a></p>
  <p><strong>Additional Information</strong></p>
  <p>The input file contains more than 500.000 rows with roughly 800 stations.</p>