Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
groups = chunkBy(df.array("page_title"), 20)
Insert cell
docs = {
let opts = { lang: lang, "Api-User-Agent": "wtf_wikipedia example" };

const doit = function (group) {
return wtf.fetch(group, opts); //returns a promise
};
//only allow three requests at a time
return slow.three(groups, doit).then((responses) => {
//flatten the results
return [].concat.apply([], responses);
});
}
Insert cell
cats = {
return docs.map((doc) => {
let categories = null;
if (doc.categories) {
categories = doc.categories();
}
return categories;
});
}
Insert cell
allcats = [].concat.apply([], cats)
Insert cell
dfc = aq.from(_.countBy(allcats)).orderby(aq.desc("value"))
Insert cell
wtf = require('wtf_wikipedia')
Insert cell
slow = require("slow")
Insert cell
chunkBy = function(arr, chunkSize) {
var groups = [], i;
for (i = 0; i < arr.length; i += chunkSize) {
groups.push(arr.slice(i, i + chunkSize));
}
return groups;
}

Insert cell
wtf.version
Insert cell
import { aq, op } from "@uwdata/arquero"
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
username: "PAC2",
wikipedia: "en.wikipedia.org"
};
if (params.has("username")) {
defaults.username = params.get("username");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}

return defaults;
}
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
import { get_pagescreated } from "@pac02/look-at-your-list-of-created-articles-with-the-xtools-page-ap"
Insert cell
data = {
let result = [];
let offset = "";
while (offset !== undefined) {
let data = await get_pagescreated({
username: username,
wikipedia: wikipedia,
offset: offset
});
offset = data.continue;
result = result.concat(aq.from(Object.values(data.pages[0])));
yield result;
}
return result;
}
Insert cell
df = data[0].union(data)
Insert cell
lang = wikipedia.replace(".wikipedia.org", "")
Insert cell
import { BubbleChart } from "@d3/bubble-chart"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more