code: def alpha_diversity(self, metric="simpson", rank="auto"):
          
          if metric not in ("simpson", "chao1", "shannon"):
              raise OneCodexException(
                  "For alpha diversity, metric must be one of: simpson, chao1, shannon"
              )
  
          # needs read counts, not relative abundances
          if self._guess_normalized():
              raise OneCodexException("Alpha diversity requires unnormalized read counts.")
  
          df = self.to_df(rank=rank, normalize=False)
  
          output = {"classification_id": [], metric: []}
  
          for c_id in df.index:
              output["classification_id"].append(c_id)
              output[metric].append(
                  skbio.diversity.alpha_diversity(metric, df.loc[c_id].tolist(), [c_id]).values[0]
              )
  
          return pd.DataFrame(output).set_index("classification_id")
docs: Caculate the diversity within a community.
  
          Parameters
          ----------
          metric : {'simpson', 'chao1', 'shannon'}
              The diversity metric to calculate.
          rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional
              Analysis will be restricted to abundances of taxa at the specified level.
  
          Returns
          -------
          pandas.DataFrame, a distance matrix.