Market Basket Analysis with Pandas

Market Basket Analysis with Pandas

What items are usually bought together? In this post, we will analyze the grocery dataset available on Kaggle. Let’s start with reading the dataset.

Market basket analysis is a common data science practice implemented by retailers. The goal is to discover the associations among items. It is very important to have an idea of what people tend to buy together.

Having a decent market basket analysis provides useful insight for aisle organizations, sales, marketing campaigns, and more.

In this post, we will analyze the grocery dataset available on Kaggle. Let’s start with reading the dataset.

import numpy as np
import pandas as pd

groceries = pd.read_csv("/content/Groceries_dataset.csv")
groceries.shape
(38765, 3)
groceries.head()

The dataset is organized in a way that each row represents an item purchased on a given day by a particular customer.

Before starting on the analysis, we should check the data types, and if there are any missing values.

groceries.isna().sum().sum()
0

groceries.dtypes
Member_number       int64 
Date               object 
itemDescription    object

There is no missing value but the data type of “Date” column should be converted to datetime which can be done with the to_datetime function of pandas.

groceries.Date = pd.to_datetime(groceries.Date)

programming data-science artificial-intelligence pandas machine-learning

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Most popular Data Science and Machine Learning courses — July 2020

Most popular Data Science and Machine Learning courses — August 2020. This list was last updated in August 2020 — and will be updated regularly so as to keep it relevant

Artificial Intelligence vs Machine Learning vs Data Science

Artificial Intelligence, Machine Learning, and Data Science are amongst a few terms that have become extremely popular amongst professionals in almost all the fields.

Pipelines in Machine Learning | Data Science | Machine Learning | Python

Machine Learning Pipelines performs a complete workflow with an ordered sequence of the process involved in a Machine Learning task. The Pipelines can also

Data Science Projects | Data Science | Machine Learning | Python

Practice your skills in Data Science with Python, by learning and then trying all these hands-on, interactive projects, that I have posted for you.

Data Science Projects | Data Science | Machine Learning | Python

Practice your skills in Data Science with Python, by learning and then trying all these hands-on, interactive projects, that I have posted for you.