Feedback about page view time series visualizer

I would appreciate it if someone takes the time to read my code and give me some feedback.

Here is my code

Thanks

As it can be seen project don’t need much code, but at the same time it’s easy to over complicate things in such case. This didn’t happen here, so that’s good. Some comments and things that caught my eye. Keep in mind these are just pointers what can be looked at and possibly improved.

Regarding lines:

from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()

Is this used for anything? It doesn’t seem to have any impact anywhere. Maybe it’s some not needed leftover?

Regarding lines:

df_box['month'] = [d.strftime('%b') for d in df_box.date]

months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
          "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
df_box['month'] = pd.Categorical(df_box['month'], categories=months, ordered=True)

I was wondering for a bit why include all these lines. Considering that first line sets month column with months as abbreviated and that is part of what last line does… So after removing it I now understand why it was put there :slight_smile:, although this could be achieved as well by passing months as order argument in the sns.boxplot call.

Regarding

df_bar_ave

Using ave is unclear here, I needed to look deeper to figure out what it means. More clear abbreviation would be probably avg. Writing full average beats both previous options.

Regarding line

plt.legend(fontsize =10, labels=months)

Just not needed space before equal sign here.

Long lines
Few lines are way too long, making function calls harder to read than necessary. Python’s PEP 8 has some examples where to put line breaks to make reading easier.

Bar plot
Bar plot has not visible labels.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.