title: Pandonic way of adding two Series with respect to bin-membership of index
body: <h3>Setup</h3>
  
  <pre><code>&gt;&gt;&gt; import pandas as pd
  &gt;&gt;&gt; import numpy as np
  &gt;&gt;&gt; s1 = pd.Series([100, 1000, 10000], index=[0, 2, 5])
  s1
  0      100
  2     1000
  5    10000
  dtype: int64
  &gt;&gt;&gt; s2 = pd.Series(np.arange(7)*10)
  &gt;&gt;&gt; s2
  0     0
  1    10
  2    20
  3    30
  4    40
  5    50
  6    60
  dtype: int32
  </code></pre>
  
  <p>Assumptions:</p>
  
  <ul>
  <li>The index of <code>s1</code> is guaranteed to be monotonically increasing.  </li>
  <li>There is no index in <code>s2</code> smaller than the minimum index of <code>s1</code>.</li>
  </ul>
  
  <p><strong>Clarification</strong>: The index of <code>s2</code> cannot be assumed to have any particular order!</p>
  
  <h3>Desired result</h3>
  
  <p>I want to add the values of <code>s1</code> to the values of <code>s2</code> as follows (see comments for explanation):</p>
  
  <pre><code>&gt;&gt;&gt; result
  0      100 # 100 + 0, because index 0 is in [0, 2)
  1      110 # 100 + 10, because index 1 is in [0, 2)
  2     1020 # 1000 + 20, because index 2 is in [2, 5)
  3     1030 # 1000 + 20, because index 3 is in [2, 5)
  4     1040 # 1000 + 40, because index 4 is in [2, 5)
  5    10050 # 10000 + 50, because index 5 is in [5, inf)
  6    10060 # 10000 + 50, because index 6 is in [5, inf)
  dtype: int64
  </code></pre>
  
  <h3>Attempt</h3>
  
  <p>I created versions of <code>s1</code> and <code>s2</code> where the bins are the index.</p>
  
  <pre><code>&gt;&gt;&gt; edges = [*s1.index, np.inf]
  &gt;&gt;&gt; s1_binned = pd.Series(s1.values, index=pd.cut(s1.index, bins=edges, right=False))
  &gt;&gt;&gt; s2_binned = pd.Series(s2.values, index=pd.cut(s2.index, bins=edges, right=False))
  s1_binned
  [0.0, 2.0)      100
  [2.0, 5.0)     1000
  [5.0, inf)    10000
  dtype: int64
  &gt;&gt;&gt; s2_binned
  [0.0, 2.0)     0
  [0.0, 2.0)    10
  [2.0, 5.0)    20
  [2.0, 5.0)    30
  [2.0, 5.0)    40
  [5.0, inf)    50
  [5.0, inf)    60
  dtype: int32
  </code></pre>
  
  <p>Then I indexed into <code>s1</code> with the index of <code>s2</code> to get the values to add.</p>
  
  <pre><code>&gt;&gt;&gt; to_add = s1_binned[s2_binned.index]
  &gt;&gt;&gt; to_add
  [0.0, 2.0)      100
  [0.0, 2.0)      100
  [2.0, 5.0)     1000
  [2.0, 5.0)     1000
  [2.0, 5.0)     1000
  [5.0, inf)    10000
  [5.0, inf)    10000
  dtype: int64
  </code></pre>
  
  <p>Finally I can add the values of <code>to_add</code> to <code>s2</code>.</p>
  
  <pre><code>&gt;&gt;&gt; s2 + to_add.values
  0      100
  1      110
  2     1020
  3     1030
  4     1040
  5    10050
  6    10060
  dtype: int64
  </code></pre>
  
  <p>I have the feeling that there is a better solution, but I don't have much experience with "mapping" values to bins.</p>