Business Metric - Churn Rate

Hi everyone,

I am trying to repeat the exercise no. 8 of Business Metrics mission (https://app.dataquest.io/m/468/business-metrics/8/churn-rate) also on Jupyter. Everything seemed to work fine but when I uncommented the code present in the screen I got this error:

arange = import(“numpy”).arange
Ellipse = import(“matplotlib”).patches.Ellipse
ax = churn.plot(x=“yearmonth”, y=“churn_rate”, figsize=(12,6), rot=45, marker=".")
start, end = ax.get_xlim()
ax.get_xticks()
ax.set_xticks(arange(2, end, 3))
ax.set_xticklabels(yearmonths[2::3])
circle = Ellipse((35, churn.loc[churn.yearmonth == “201312”, “churn_rate”].iloc[0]),
5, 0.065, color=‘sandybrown’, fill=False
)
ax.add_artist(circle)
ax.xaxis.label.set_visible(False)
ax.spines[‘top’].set_visible(False)
ax.spines[‘right’].set_visible(False)
ax.get_legend().remove()

What actually happened:


ValueError Traceback (most recent call last)
in
5 ax.get_xticks()
6 ax.set_xticks(arange(2, end, 3))
----> 7 ax.set_xticklabels(yearmonths[2::3])
8 circle = Ellipse((35, churn.loc[churn.yearmonth == “201312”, “churn_rate”].iloc[0]),
9 5, 0.065, color=‘sandybrown’, fill=False

~\anaconda3\lib\site-packages\matplotlib\axes_base.py in wrapper(self, *args, **kwargs)
61
62 def wrapper(self, *args, **kwargs):
—> 63 return get_method(self)(*args, **kwargs)
64
65 wrapper.module = owner.module

~\anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*args, **kwargs)
449 “parameter will become keyword-only %(removal)s.”,
450 name=name, obj_type=f"parameter of {func.name}()")
–> 451 return func(*args, **kwargs)
452
453 return wrapper

~\anaconda3\lib\site-packages\matplotlib\axis.py in _set_ticklabels(self, labels, fontdict, minor, **kwargs)
1791 if fontdict is not None:
1792 kwargs.update(fontdict)
-> 1793 return self.set_ticklabels(labels, minor=minor, **kwargs)
1794
1795 @cbook._make_keyword_only(“3.2”, “minor”)

~\anaconda3\lib\site-packages\matplotlib\axis.py in set_ticklabels(self, ticklabels, minor, **kwargs)
1712 # remove all tick labels, so only error for > 0 ticklabels
1713 if len(locator.locs) != len(ticklabels) and len(ticklabels) != 0:
-> 1714 raise ValueError(
1715 “The number of FixedLocator locations”
1716 f" ({len(locator.locs)}), usually from a call to"

ValueError: The number of FixedLocator locations (16), usually from a call to set_ticks, does not match the number of ticklabels (15).

I don’t know how to fix this. What’s wrong?