renamed file to match the content
[harrypotter-wikipedia-cdsw] / harrypotter_anon_edits.ipynb
1 {
2  "cells": [
3   {
4    "cell_type": "code",
5    "execution_count": null,
6    "metadata": {},
7    "outputs": [],
8    "source": [
9     "from csv import DictReader"
10    ]
11   },
12   {
13    "cell_type": "code",
14    "execution_count": null,
15    "metadata": {},
16    "outputs": [],
17    "source": [
18     "input_file = open(\"hp_wiki.tsv\", 'r', encoding='utf-8')"
19    ]
20   },
21   {
22    "cell_type": "code",
23    "execution_count": null,
24    "metadata": {},
25    "outputs": [],
26    "source": [
27     "num_edits = 0\n",
28     "num_anon = 0\n",
29     "for row in DictReader(input_file, delimiter=\"\\t\"):\n",
30     "    num_edits = num_edits + 1\n",
31     "    if row[\"anon\"] == \"True\":\n",
32     "        num_anon = num_anon + 1\n",
33     "\n",
34     "prop_anon = num_anon / num_edits"
35    ]
36   },
37   {
38    "cell_type": "code",
39    "execution_count": null,
40    "metadata": {},
41    "outputs": [],
42    "source": [
43     "print(f\"total edits: {num_edits}\")\n",
44     "print(f\"anon edits: {num_anon}\")\n",
45     "print(f\"proportion anon: {prop_anon}\")"
46    ]
47   },
48   {
49    "cell_type": "code",
50    "execution_count": null,
51    "metadata": {},
52    "outputs": [],
53    "source": []
54   }
55  ],
56  "metadata": {
57   "kernelspec": {
58    "display_name": "Python 3",
59    "language": "python",
60    "name": "python3"
61   },
62   "language_info": {
63    "codemirror_mode": {
64     "name": "ipython",
65     "version": 3
66    },
67    "file_extension": ".py",
68    "mimetype": "text/x-python",
69    "name": "python",
70    "nbconvert_exporter": "python",
71    "pygments_lexer": "ipython3",
72    "version": "3.7.3"
73   }
74  },
75  "nbformat": 4,
76  "nbformat_minor": 2
77 }

Benjamin Mako Hill || Want to submit a patch?