Skip to content

Instantly share code, notes, and snippets.

@lundquist-ecology-lab
Last active March 6, 2023 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lundquist-ecology-lab/0bbae810fb8dfa4a67a5a1377febffee to your computer and use it in GitHub Desktop.
Save lundquist-ecology-lab/0bbae810fb8dfa4a67a5a1377febffee to your computer and use it in GitHub Desktop.
Basic summary stats using pandas in Python
# Calculating mean, and other summary statistics in Python with examples
import pandas as pd
import numpy as np
from palmerpenguins import load_penguins
penguins = load_penguins()
bill_length_mm = penguins['bill_length_mm'].dropna()
# Sample mean
mean = np.mean(bill_length_mm)
# Sample standard deviation
std_dev = np.std(bill_length_mm)
# Sample size
n = len(bill_length_mm)
# Summary stats using pandas
print(bill_length_mm.describe())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment