Glossary

`(election_date - df["date"]).dt.days`

This subtracts the poll date from the election date, producing a `timedelta` object. The `.dt.days` accessor extracts the number of days as an integer. A poll fielded on October 20 for a November 5 election produces `(2024-11-05 - 2024-10-20).days = 16`. The `.clip(lower=0)` call ensures that polls

Learn More

Related Terms