calculate_correlation

def calculate_correlation(csv_path: str,
                          column1: str,
                          column2: str,
                          method: str = "pearson") -> float

Calculate the correlation between two columns in a CSV file.

Arguments:

  • csv_path str - The path to the CSV file.
  • column1 str - The name of the first column.
  • column2 str - The name of the second column.
  • method str or callable, optional - The method used to calculate the correlation.
    • ‘pearson’ (default): Pearson correlation coefficient.
    • ‘kendall’: Kendall Tau correlation coefficient.
    • ‘spearman’: Spearman rank correlation coefficient.
    • callable: A custom correlation function that takes two arrays and returns a scalar.

Returns:

  • float - The correlation coefficient between the two columns.