title: Drop duplicated indices/columns that only contain a sub-string from a dataframe
body: <p><em><strong>Context:</strong></em> I have a dataframe that contains duplicated indices, howerver, I'd only like to drop the duplicated indices that contain a specific pattern</p>
  <p>For example if we have this dataframe:</p>
  <pre><code>tt = pd.DataFrame({'A':[1,2,3,10,10,2,3,4,20,20]}, index=['Sum_2019','X','Y','Sum_2020','Sum_2020','A','B','C','Sum_2021','Sum_2021'])
  
             A
  Sum_2019   1
  X          2
  Y          3
  Sum_2020  10
  Sum_2020  10
  X          2
  Y          3
  Z          4
  Sum_2021  20
  Sum_2021  20
  </code></pre>
  <p><em><strong>Desired output:</strong></em> How can I drop only the indices that contain the pattern &quot;Sum_&quot; or each given year (2020 repeated) from the dataframe?</p>
  <pre><code>           A
  Sum_2019   1
  X          2
  Y          3
  Sum_2020  10
  X          2
  Y          3
  C          4
  Sum_2021  20
  </code></pre>
  <p><em><strong>Attempts:</strong></em></p>
  <p>I was trying to do this:</p>
  <pre><code>        df= df[~df.index.duplicated(keep='first')]
  </code></pre>
  <p>But this also removes the indices &quot;X&quot; and &quot;Y&quot; that I want to keep.</p>
  <p>Thank you!</p>