fetch_views()

Fetch daily pageviews for a single Wikipedia article.

Usage

fetch_views(
    article,
    start=DATA_FLOOR,
    end=None,
    project="en.wikipedia",
    granularity="daily"
)

Parameters

article: str

Article title, e.g. "Tamagotchi". Spaces are converted to underscores and the title is URL-encoded for you. Redirects are resolved first.

start: dt.date = DATA_FLOOR

Inclusive date range. Data is available from 2015-07-01.

end: dt.date = DATA_FLOOR

Inclusive date range. Data is available from 2015-07-01.

project: str = "en.wikipedia"

Wikimedia project, e.g. "en.wikipedia".

granularity: str = "daily"
"daily" or "monthly".

Returns

pd.DataFrame
Columns date, article, views. Empty (with a warning) if the article has no data for the range.

Examples

>>> df = fetch_views("Furby", start=dt.date(2020, 1, 1), end=dt.date(2020, 12, 31))  # doctest: +SKIP
>>> df.views.sum() > 0  # doctest: +SKIP

True