title: Mask lower triangluar portion of pandas DataFrame
body: <p>This is a dataframe output I'm generating, which is a 5 x 5 correlation matrix.</p>
  
  <pre><code>     A         B          C          D          E
  A    1.00000  -0.277360   0.653920  -0.479600   0.513890
  B   -0.27736   1.000000  -0.790648   0.885801  -0.482763
  C    0.65392  -0.790648   1.000000  -0.876451   0.672148
  D   -0.47960   0.885801  -0.876451   1.000000  -0.756182
  E    0.51389  -0.482763   0.672148  -0.756182   1.000000
  </code></pre>
  
  <p>I'd like to obtain the overall mean of this dataframe but for that I'd need to ignore duplicate values (leaving only the first occurrence). I tried using</p>
  
  <pre><code>df.drop_duplicates(inplace=True)
  </code></pre>
  
  <p>However, it returns the df unchanged, which I believe is because <code>drop_duplicates()</code> will remove rows, but not replace individual cells with <code>NaN</code>.</p>
  
  <p>Any suggestions on how to achieve this? (desired output below)</p>
  
  <p>Note that <strong><em>I'd also need to specifically remove correlations == 1</em></strong>, as they are unnecessary.</p>
  
  <pre><code>     A         B          C          D          E
  A    NaN      -0.277360   0.653920  -0.479600   0.513890
  B    NaN       NaN       -0.790648   0.885801  -0.482763
  C    NaN       NaN        NaN       -0.876451   0.672148
  D    NaN       NaN        NaN        NaN       -0.756182
  E    NaN       NaN        NaN        NaN        NaN     
  </code></pre>