parameters: (
          self,
          method: str | Callable[[np.ndarray, np.ndarray], float] = "pearson",
          min_periods: int = 1,
      )
return_statement: return self._constructor(correl, index=idx, columns=cols)
docstring: Compute pairwise correlation of columns, excluding NA/null values.
  
          Parameters
          ----------
          method : {'pearson', 'kendall', 'spearman'} or callable
              Method of correlation:
  
              * pearson : standard correlation coefficient
              * kendall : Kendall Tau correlation coefficient
              * spearman : Spearman rank correlation
              * callable: callable with input two 1d ndarrays
                  and returning a float. Note that the returned matrix from corr
                  will have 1 along the diagonals and will be symmetric
                  regardless of the callable's behavior.
          min_periods : int, optional
              Minimum number of observations required per pair of columns
              to have a valid result. Currently only available for Pearson
              and Spearman correlation.
  
          Returns
          -------
          DataFrame
              Correlation matrix.
  
          See Also
          --------
          DataFrame.corrwith : Compute pairwise correlation with another
              DataFrame or Series.
          Series.corr : Compute the correlation between two Series.
  
          Examples
          --------
          >>> def histogram_intersection(a, b):
          ...     v = np.minimum(a, b).sum().round(decimals=1)
          ...     return v
          >>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
          ...                   columns=['dogs', 'cats'])
          >>> df.corr(method=histogram_intersection)
                dogs  cats
          dogs   1.0   0.3
          cats   0.3   1.0
docstring_summary: Compute pairwise correlation of columns, excluding NA/null values.
docstring_tokens: Compute pairwise correlation of columns excluding NA / null values .
function: def corr(
          self,
          method: str | Callable[[np.ndarray, np.ndarray], float] = "pearson",
          min_periods: int = 1,
      ) -> DataFrame:
          """
          Compute pairwise correlation of columns, excluding NA/null values.
  
          Parameters
          ----------
          method : {'pearson', 'kendall', 'spearman'} or callable
              Method of correlation:
  
              * pearson : standard correlation coefficient
              * kendall : Kendall Tau correlation coefficient
              * spearman : Spearman rank correlation
              * callable: callable with input two 1d ndarrays
                  and returning a float. Note that the returned matrix from corr
                  will have 1 along the diagonals and will be symmetric
                  regardless of the callable's behavior.
          min_periods : int, optional
              Minimum number of observations required per pair of columns
              to have a valid result. Currently only available for Pearson
              and Spearman correlation.
  
          Returns
          -------
          DataFrame
              Correlation matrix.
  
          See Also
          --------
          DataFrame.corrwith : Compute pairwise correlation with another
              DataFrame or Series.
          Series.corr : Compute the correlation between two Series.
  
          Examples
          --------
          >>> def histogram_intersection(a, b):
          ...     v = np.minimum(a, b).sum().round(decimals=1)
          ...     return v
          >>> df = pd.DataFrame([(.2, .3), (.0, .6), (.6, .0), (.2, .1)],
          ...                   columns=['dogs', 'cats'])
          >>> df.corr(method=histogram_intersection)
                dogs  cats
          dogs   1.0   0.3
          cats   0.3   1.0
          """
          numeric_df = self._get_numeric_data()
          cols = numeric_df.columns
          idx = cols.copy()
          mat = numeric_df.to_numpy(dtype=float, na_value=np.nan, copy=False)
  
          if method == "pearson":
              correl = libalgos.nancorr(mat, minp=min_periods)
          elif method == "spearman":
              correl = libalgos.nancorr_spearman(mat, minp=min_periods)
          elif method == "kendall" or callable(method):
              if min_periods is None:
                  min_periods = 1
              mat = mat.T
              corrf = nanops.get_corr_func(method)
              K = len(cols)
              correl = np.empty((K, K), dtype=float)
              mask = np.isfinite(mat)
              for i, ac in enumerate(mat):
                  for j, bc in enumerate(mat):
                      if i > j:
                          continue
  
                      valid = mask[i] & mask[j]
                      if valid.sum() < min_periods:
                          c = np.nan
                      elif i == j:
                          c = 1.0
                      elif not valid.all():
                          c = corrf(ac[valid], bc[valid])
                      else:
                          c = corrf(ac, bc)
                      correl[i, j] = c
                      correl[j, i] = c
          else:
              raise ValueError(
                  "method must be either 'pearson', "
                  "'spearman', 'kendall', or a callable, "
                  f"'{method}' was supplied"
              )
  
          return self._constructor(correl, index=idx, columns=cols)
function_tokens: def corr ( self , method : str | Callable [ [ np . ndarray , np . ndarray ] , float ] = "pearson" , min_periods : int = 1 , ) -> DataFrame : numeric_df = self . _get_numeric_data ( ) cols = numeric_df . columns idx = cols . copy ( ) mat = numeric_df . to_numpy ( dtype = float , na_value = np . nan , copy = False ) if method == "pearson" : correl = libalgos . nancorr ( mat , minp = min_periods ) elif method == "spearman" : correl = libalgos . nancorr_spearman ( mat , minp = min_periods ) elif method == "kendall" or callable ( method ) : if min_periods is None : min_periods = 1 mat = mat . T corrf = nanops . get_corr_func ( method ) K = len ( cols ) correl = np . empty ( ( K , K ) , dtype = float ) mask = np . isfinite ( mat ) for i , ac in enumerate ( mat ) : for j , bc in enumerate ( mat ) : if i > j : continue valid = mask [ i ] & mask [ j ] if valid . sum ( ) < min_periods : c = np . nan elif i == j : c = 1.0 elif not valid . all ( ) : c = corrf ( ac [ valid ] , bc [ valid ] ) else : c = corrf ( ac , bc ) correl [ i , j ] = c correl [ j , i ] = c else : raise ValueError ( "method must be either 'pearson', " "'spearman', 'kendall', or a callable, " f"'{method}' was supplied" ) return self . _constructor ( correl , index = idx , columns = cols )