Sitemap
Data Science Collective

Advice, insights, and ideas from the Medium data science community

Member-only story

QUICK SUCCESS DATA SCIENCE

Predict Mardi Gras with Python and the Computus Algorithm

How often does Mardi Gras fall on Leap Day?

6 min readFeb 17, 2025

--

Press enter or click to view image in full size
A desk calendar opened to February 29 is festooned with colorful Mardi Gras beads and a mask.
Desk calendar by DALL-E3

Although we haven’t lived in New Orleans for decades, my wife still updates our digital calendar for the Mardi Gras event. Recently, she noticed something interesting: in the 2028 leap year, Mardi Gras falls on the leap day, February 29th — a rare alignment of two calendar quirks.

Mardi Gras is tied to Easter Sunday, an annual celebration without a fixed date. Having Mardi Gras fall on the leap day is surely a rare event; but how rare? In this Quick Sucess Data Science project, we’ll use Python to find all the occurrences of Mardi Gras on a leap day over a specified timespan and calculate the probability.

Mastering date manipulation is a valuable skill for data scientists. Whether you’re in finance tracking Federal Reserve meetings or in astronomy predicting planetary conjunctions, understanding how to work with dates programmatically opens up a world of possibilities.

The Computus Algorithm

Mardi Gras is linked to Easter Sunday, celebrated on the first Sunday after the first full moon on or after the spring equinox. As a result, Easter always falls within the range of March 22nd to April…

--

--

Lee Vaughan
Lee Vaughan

Written by Lee Vaughan⁠

Author of “Python Tools for Scientists,” “Impractical Python Projects,” and “Real World Python.” Former Senior Principal Scientist at ExxonMobil.

Data Science Collective
Data Science Collective

Published in Data Science Collective

Advice, insights, and ideas from the Medium data science community