code: def correl(
      df,
      periods=21,
      columns=None,
      include=True,
      str=None,
      detail=False,
      how="value",
      **correl_kwargs,
  ):
      """
      how : string
              value
              pct_chg
              diff
      """
  
      def _correl(
          df,
          periods=21,
          columns=None,
          include=True,
          str=None,
          detail=False,
          **correl_kwargs,
      ):
          study = "CORREL"
          df, _df, columns = validate(df, columns)
  
          _df["CORREL"] = (
              df[columns[0]]
              .rolling(window=periods, **correl_kwargs)
              .corr(df[columns[1]])
          )
  
          str = (
              str
              if str
              else "CORREL({column1},{column2},{period})".format(
                  column1=columns[0], column2=columns[1], period=periods
              )
          )
          return rename(
              df, _df, study, periods, columns, include, str, detail
          )
  
      columns = df.columns if not columns else columns
      if len(columns) != 2:
          raise StudyError(
              "2 Columns need to be specified for a correlation study"
          )
      periods = make_list(periods)
      if how == "pct_chg":
          df = df[columns].pct_change()
      elif how == "diff":
          df = df[columns].diff()
      __df = pd.concat(
          [
              _correl(
                  df, columns=columns, periods=y, include=False, str=str
              )
              for y in periods
          ],
          axis=1,
      )
      if include:
          return pd.concat([df, __df], axis=1)
      else:
          return __df
  
imports: import pandas
  import numpy
  from plotly.graph_objs import Figure
  from .utils import make_list
label_desc: Use image node_id 13 for calling a global function with example usage: correl(df, periods, columns, include, str, detail, how) and returns: rename, pd, __df