title: How to add values under the diagonal of a dataframe array into a larger one based on row/column names?
body: <p>I want to build a correlation matrix of all authors of a series of articles.</p>
  
  <p>First I will build a correlation matrix of all authors to all authors initialized to zeros and represent them with a pandas dataframe.</p>
  
  <p>I will then get the author list of the first article and build a smaller dataframe initilized to ones.</p>
  
  <p>I would finally need to sum the ones under the diagonal of the latter smaller dataframe onto the large one.</p>
  
  <p>After I will repeat this for all articles the end result will be how many times each author has published along with every coauthor.</p>
  
  <p>I would love to avoid explicit iterations and leverage pandas and numpy operations as much as possible.</p>
  
  <p>Here is working code leading to my question:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  all_authors = ["a","b","c","d","e","f","g"]
  
  #create a numpy array initialized to all zeros with a side length of all_authors
  authors_num = len(all_authors)
  corr_matrix = np.zeros((authors_num,authors_num),dtype=np.int8)
  # create a pandas dataframe using the corr_matrix and add the authors names as indexes and column names
  corr_df = pd.DataFrame(data=corr_matrix,    # data
                     index=all_authors,       # row names
                     columns=all_authors)     # column names
  
  article_1_authors = ["a","b","d"]
  #create a numpy array initialized to all ones with a side length of the article authors
  authors_num = len(article_1_authors)
  corr_matrix = np.ones((authors_num,authors_num),dtype=np.int8)
  # create a pandas dataframe using the corr_matrix and add the authors names as indexes and column names
  auth_df = pd.DataFrame(data=corr_matrix,        # data
                     index=article_1_authors,     # row names
                     columns=article_1_authors)   # column names
  </code></pre>
  
  <p>So from the above dataframe I'd only need to use the a-b a-d and b-d values and sum them into corr_df</p>
  
  <p>How can I do using pandas/numpy operators avoiding for loops and other iterations if possible ? Thank you in advance</p>