docstr: Gets list of terms to display that have some interesting diachronic variation.
  
  Returns
  -------
  pd.DataFrame
  
  e.g.,
             term variable  frequency  trending
  2            in   200310        1.0  0.000000
  19          for   200310        1.0  0.000000
  20           to   200311        1.0  0.000000
docstr_tok: ["Gets","list","of","terms","to","display","that","have","some","interesting","diachronic","variation",".","Returns","--","--","--","-","pd.DataFrame","e.g.",",","term","variable","frequency","trending","2","in","200310","1.0","0.000000","19","for","200310","1.0","0.000000","20","to","200311","1.0","0.000000"]
code: def get_display_dataframe(self):
      """
      Gets list of terms to display that have some interesting diachronic variation.
  
      Returns
      -------
      pd.DataFrame
  
      e.g.,
                 term variable  frequency  trending
      2            in   200310        1.0  0.000000
      19          for   200310        1.0  0.000000
      20           to   200311        1.0  0.000000
      """
      X = self.corpus_.get_term_doc_mat()
      categories = pd.Series(self.corpus_.get_category_ids())
      cat_ar = np.array(self.corpus_.get_categories())
      cat_idx_sort = np.argsort(cat_ar)
      if self.seasonality_column_:
          seasonality_ar = np.array(
              self.corpus_.get_df()[self.seasonality_column_]
          )
  
      terms = self.corpus_.get_terms()
      category_idx_store = self.corpus_.get_category_index_store()
  
      data = {}
      seasondata = {}
      for i, cati in enumerate(cat_idx_sort):
          cat = cat_ar[cati]
          if cat >= self.start_category_ and i > self.timesteps_to_lag_:
              neg_cats = self.sorted_categores_[
                  i - self.timesteps_to_lag_ : i
              ]
              neg_mask = categories.isin(
                  category_idx_store.getidxstrictbatch(neg_cats)
              ).values
              scores = self._regress_terms(
                  X,
                  cat,
                  categories,
                  category_idx_store,
                  neg_mask,
                  terms,
              )
              data[cat] = scores
              if self.seasonality_column_:
                  neg_cats = set(
                      categories[
                          (seasonality_ar == seasonality_ar[cati])
                          & (categories != categories[cati])
                      ]
                  )
                  neg_mask = categories.isin(neg_cats).values
                  scores = self._regress_terms(
                      X,
                      cat,
                      categories,
                      category_idx_store,
                      neg_mask,
                      terms,
                  )
                  seasondata[cat] = scores
      coefs = pd.DataFrame(data)
      pos_coefs = (
          coefs.apply(lambda x: (x > 0) * x, axis=1)
          .sum(axis=1)
          .sort_values(ascending=False)
      )
  
      term_cat_counts = self.corpus_.get_term_freq_df("")[coefs.columns]
  
      def dense_percentile(x):
          # ranks = rankdata(x, 'dense')
          return pd.Series(x / x.max(), index=x.index)
  
      rank_df = pd.DataFrame(
          {
              "coefr": dense_percentile(pos_coefs),
              "freqr": dense_percentile(term_cat_counts.max(axis=1)),
              "coef": pos_coefs,
              "freq": term_cat_counts.max(axis=1),
          }
      )
      if self.seasonality_column_:
          seasoncoefs = pd.DataFrame(seasondata).sum(axis=1)
          rank_df["seasoncoefr"] = dense_percentile(
              seasoncoefs.sort_values(ascending=False)
              + np.abs(seasoncoefs.min())
          )
          weights = [2, 1, 1]
          vals = ["freqr", "coefr", "seasoncoefr"]
  
          def gethmean(x):
              if min(x[vals]) == 0:
                  return 0
              return (
                  sum(weights)
                  * 1.0
                  / sum(
                      [
                          weights[i] / x[val]
                          for i, val in enumerate(vals)
                      ]
                  )
              )
  
          rank_df["hmean"] = rank_df.apply(gethmean, axis=1)
      else:
          beta = 0.5
          rank_df["hmean"] = rank_df.apply(
              lambda x: 0
              if min(x) == 0
              else (1 + beta**2)
              * (x.coefr * x.freqr)
              / ((beta**2 * x.coefr) + x.freqr),
              axis=1,
          )
      rank_df = rank_df.sort_values(by="hmean", ascending=False)
      display_df = pd.merge(
          (
              term_cat_counts.loc[rank_df.iloc[: self.num_terms_].index]
              .reset_index()
              .melt(id_vars=["index"])
              .rename(columns={"index": "term", "value": "frequency"})
          ),
          (
              coefs.loc[rank_df.iloc[: self.num_terms_].index]
              .reset_index()
              .melt(id_vars=["index"])
              .rename(columns={"index": "term", "value": "trending"})
          ),
          on=["term", "variable"],
      )
      display_df[display_df["frequency"] == 0] = np.nan
      display_df = display_df.dropna()
      return display_df[display_df.term.isin(rank_df.index)]
  
file_path: scattertext/scattertext/diachronic/DiachronicTermMiner.py
imports: import numpy
  import pandas
  from sklearn.linear_model import LogisticRegression
  from scattertext.diachronic.BubbleDiachronicVisualization import BubbleDiachronicVisualization
  from scattertext.diachronic.DiachronicVisualizer import DiachronicVisualizer
label_desc: Use image node_id 2 for calling the DiachronicTermMiner obj's underlying member method code with example usage: obj.get_display_dataframe() and returns: display_df, pd, unknown, int