Introduction to Descriptive Statistics and Python

Greetings, data enthusiast! Today, we are diving into descriptive statistics using Python. We'll be exploring measures of centrality — mean, median, and mode — using Python libraries numpy and pandas.

Understanding Central Tendency

A central tendency finds a 'typical' value in a dataset. Our three components — the mean (average), median (mid-point), and mode (most frequently appearing) — each offer a unique perspective on centrality. The mean indicates average performance when decoding students' scores, while the median represents the middle student's performance, and the mode highlights the most common score.

Visualizing Central Tendency

This plot represents a given dataset's mean or centered location, also considered the 'average'. Imagine a seesaw balancing at its center - the mean of a dataset is where it balances out. It is a crucial statistical concept and visually helps identify where most of our data is centered around or leaning toward.

Setting up the Dataset

Our dataset is a list of individuals' ages: [23, 22, 22, 23, 24, 24, 23, 22, 21, 24, 23]. Remember, understanding your data upfront is key to conducting a meaningful analysis.

Computing Mean using Python

Calculating the mean involves adding all numbers together and then dividing by the count. Here's how you compute it in Python:

Python
import numpy as np

data = np.array([23, 22, 22, 23, 24, 24, 23, 22, 21, 24, 23])
mean = np.mean(data)  # calculates the mean
print("Mean: ", round(mean, 2))  # Mean:  22.82
Computing Median using Python

The median is the 'middle' value in an ordered dataset. This is how it is computed in Python:

import numpy as np

data = np.array([23, 22, 22, 23, 24, 24, 23, 22, 21, 24, 23])
median = np.median(data)  # calculates the median
print("Median: ", median)  # Median:  23.0
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal