How it works...
In step 1, we create another continuous variable by using pandas date functionality. This data was collected from the city of Houston on December 1, 2016. We use this date to determine how long each employee has worked for the city. When we subtract dates, as done in the second line of code, we are returned a Timedelta object whose largest unit is days. We could have simply divided this number by 365 to calculate the years of experience. Instead, we use Timedelta(1, unit='Y') to get a more precise measurement, which happens to be 365 days, 5 hours, 42 minutes and 19 seconds if you are counting at home.
Step 2 uses the seaborn Axes function regplot to create a scatter plot with the estimated regression line. It returns an Axes, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access