Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Calculate Skewness and Kurtosis for a Dataset Using Python

Calculating Skewness and Kurtosis in Python

Condition for Calculating Skewness and Kurtosis in a Dataset Using Python

  • Description:
    • Skewness:
      Skewness measures the asymmetry of the data distribution.
      • Positive Skew: Tail is longer on the right.
      • Negative Skew: Tail is longer on the left.
      • Zero Skew: Data is perfectly symmetric.
    • Kurtosis:
      Kurtosis measures the "tailedness" of the data distribution.
      • High Kurtosis: Heavy tails (extreme outliers).
      • Low Kurtosis: Light tails (few outliers).
      • Normal Kurtosis: Close to 3 (normal distribution).
Step-by-Step Process
  • Skewness:
    Calculate the mean of the dataset, subtract the mean from each data point, cube these deviations, sum them, and divide by the number of data points. Normalize by dividing by the cube of the standard deviation.
  • Kurtosis:
    Calculate the mean of the dataset, subtract the mean from each data point, raise these deviations to the fourth power, sum them, and divide by the number of data points. Normalize by dividing by the fourth power of the standard deviation. Subtract 3 to standardize against a normal distribution.
Sample Source Code
  • # Import necessary libraries
    import pandas as pd

    df = pd.read_csv('/home/soft23/Downloads/company_sales_data.csv')

    print("ORIGINAL DATASET: ")
    print(df)
    print()

    # Skewness calculation
    print("THE VALUE OF SKEWNESS:")
    print(df.skew())
    print()

    # Kurtosis calculation
    print("THE VALUE OF KURTOSIS:")
    print(df.kurtosis())

Screenshots
  • Skewness and Kurtosis Calculation