Skip to content

Introduction to Statistics in Python

Run the hidden code cell below to import the data used in this course.

Take Notes

Three measures of centre:

  1. mean
  2. median
  3. mode mean
# Importing numpy and pandas
import numpy as np
import pandas as pd

# Importing the course datasets
deals = pd.read_csv("datasets/amir_deals.csv")
happiness = pd.read_csv("datasets/world_happiness.csv")
food = pd.read_csv("datasets/food_consumption.csv")
deals.head()
happiness.head()
food.head()

#to know about the dataset

np.mean(deals['amount'])

#sorting the values from lower to higher

deals['amount'].sort_values()
Hidden output

Mode is the most frequent value in the data. we will count the number of times an item is there in the dataset using value_counts() method.

deals['product'].value_counts()
Hidden output
import statistics
statistics.mode(deals['amount'])

to take mean and median or more than one function together in a code. use .agg() method

Ch-2 RANDOM NUMBER AND PROBABILITY