Awesome Jupyter Traffic Statistics

Various traffic statistics and charts for the Awesome Jupyter repo on GitHub
awesome-jupyter
github
Published

January 11, 2023

This post contains several charts that show various traffic statistics for the Awesome Jupyter repo on GitHub. By default, GitHub only provides traffic statistics for the last 14 days. For the Awesome Jupyter repo, sangonzal/repository-traffic-action is set up as a GitHub workflow to preserve the traffic history for longer periods. The traffic data is stored in .csv files on the traffic branch of the repository and updated daily via the workflow.

The plots in this post are Vega charts (generated with Altair) that point directly at the dynamically updating .csv files so the charts are updated at view-time without having to re-render the post.

Views

Number of views over time

The chart below shows the number of views on the repository over time. Both the number of unique views as well as the total number of views are shown in different colours. The dotted line shows the 7-day moving average.

Code
import altair as alt

url = "https://markusschanta.github.io/awesome-jupyter/traffic/views.csv"

views_base = alt.Chart(url).transform_calculate(
    "Total Views", "datum.total_views"
).transform_calculate(
    "Unique Views", "datum.unique_views"
).transform_fold(
    ['Total Views', 'Unique Views'],
).transform_calculate(
    "Weekday", "day(datum._date)"
)

bars = views_base.mark_bar().encode(
    x=alt.X('yearmonthdate(_date):T', title=''),
    y=alt.Y('value:Q', stack=None, title='Value'),
    color=alt.Color('key:O', title='Metric', scale=alt.Scale(scheme='blues')),
    tooltip=[
        alt.Tooltip('_date:T', title='Date'), 
        alt.Tooltip('key:O', title='Metric'), 
        alt.Tooltip('value:Q', title='Value')
    ]
).properties(
    height=300,
    width=600
)

line = views_base.mark_line(
    color='black',
    size=2,
    strokeDash=[3,3]
).transform_window(
    rolling_mean='mean(Unique Views)',
    frame=[7, 0]
).encode(
    x='_date:T',
    y='rolling_mean:Q'
)

bars + line

Number of views per week

The chart below shows the average number of daily unique views on the repository per calendar week.

Code
views_base.mark_bar().encode(
    x=alt.X('yearweek(_date):O', title=''),
    y=alt.Y('mean(Unique Views):Q', stack=None, title='Daily Average Unique Views'),
    tooltip=[
        alt.Tooltip('yearweek(_date):O', title='Week'),
        alt.Tooltip('mean(Unique Views):Q', title='Daily Average Unique Views', format='.3')
    ]
).properties(
    height=300,
    width=600
)

Number of views per weekday

The chart below shows the average number of daily unique views on the repository per weekday (ie. day of the week).

Code
views_base.mark_bar().encode(
    x=alt.X('day(_date):O', title='', axis=alt.Axis(format="%A")),
    y=alt.Y('mean(Unique Views):Q', stack=None),
    tooltip=[
        alt.Tooltip('day(_date):O', title='Weekday', format="%A")
    ]
).properties(
    height=300,
    width=600
)

Clones

Number of clones over time

The chart below shows the number of clones on the repository over time. Both the number of unique clones as well as the total number of clones are shown in different colours. The dotted line shows the 7-day moving average.

Code
import altair as alt

url = "https://markusschanta.github.io/awesome-jupyter/traffic/clones.csv"

clones_base = alt.Chart(url).transform_calculate(
    "Total Clones", "datum.total_clones"
).transform_calculate(
    "Unique Clones", "datum.unique_clones"
).transform_fold(
    ['Total Clones', 'Unique Clones'],
).transform_calculate(
    "Weekday", "day(datum._date)"
)

bars = clones_base.mark_bar().encode(
    x=alt.X('yearmonthdate(_date):T', title=''),
    y=alt.Y('value:Q', stack=None, title='Value'),
    color=alt.Color('key:O', title='Metric', scale=alt.Scale(scheme='greens')),
    tooltip=[
        alt.Tooltip('_date:T', title='Date'), 
        alt.Tooltip('key:O', title='Metric'), 
        alt.Tooltip('value:Q', title='Value')
    ]
).properties(
    height=300,
    width=600
)

line = clones_base.mark_line(
    color='black',
    size=2,
    strokeDash=[3,3]
).transform_window(
    rolling_mean='mean(Unique Clones)',
    frame=[7, 0]
).encode(
    x='_date:T',
    y='rolling_mean:Q'
)

bars + line

Number of clones per week

The chart below shows the average number of daily unique clones of the repository per calendar week.

Code
clones_base.mark_bar().encode(
    x=alt.X('yearweek(_date):O', title=''),
    y=alt.Y('mean(Unique Clones):Q', stack=None, title='Daily Average Unique Clones'),
    color=alt.Color('color:O', legend=None, scale=alt.Scale(scheme='greens')),
    tooltip=[
        alt.Tooltip('yearweek(_date):O', title='Week'),
        alt.Tooltip('mean(Unique Clones):Q', title='Daily Average Unique Clones', format='.3')
    ]
).properties(
    height=300,
    width=600
)

Number of clones per weekday

The chart below shows the average number of daily unique clones of the repository per weekday (ie. day of the week).

Code
clones_base.mark_bar().encode(
    x=alt.X('day(_date):O', title='', axis=alt.Axis(format="%A")),
    y=alt.Y('mean(Unique Clones):Q', stack=None, title='Daily Average Unique Clones'),
    color=alt.Color('color:O', legend=None, scale=alt.Scale(scheme='greens')),
    tooltip=[
        alt.Tooltip('yearweek(_date):O', title='Week'),
        alt.Tooltip('mean(Unique Clones):Q', title='Daily Average Unique Clones', format='.3')
    ]
).properties(
    height=300,
    width=600
)