ag2435 commited on
Commit
7539963
·
1 Parent(s): a3898b5

added notebooks

Browse files
Files changed (2) hide show
  1. so_bigquery.ipynb +1546 -0
  2. stackexchange.ipynb +0 -0
so_bigquery.ipynb ADDED
@@ -0,0 +1,1546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Run SQL queries on StackExchange Data Explorer"
8
+ ]
9
+ },
10
+ {
11
+ "cell_type": "code",
12
+ "execution_count": 46,
13
+ "metadata": {},
14
+ "outputs": [],
15
+ "source": [
16
+ "from google.cloud import bigquery\n",
17
+ "import pandas as pd"
18
+ ]
19
+ },
20
+ {
21
+ "cell_type": "code",
22
+ "execution_count": 2,
23
+ "metadata": {},
24
+ "outputs": [],
25
+ "source": [
26
+ "# Create a client\n",
27
+ "client = bigquery.Client(project='mlcore-418622')"
28
+ ]
29
+ },
30
+ {
31
+ "cell_type": "markdown",
32
+ "metadata": {},
33
+ "source": [
34
+ "## SELECT questions"
35
+ ]
36
+ },
37
+ {
38
+ "cell_type": "code",
39
+ "execution_count": 16,
40
+ "metadata": {},
41
+ "outputs": [],
42
+ "source": [
43
+ "# stackoverflow questions\n",
44
+ "query = \"\"\"\n",
45
+ " SELECT *\n",
46
+ " FROM `bigquery-public-data.stackoverflow.posts_questions`\n",
47
+ " LIMIT 10\n",
48
+ "\"\"\""
49
+ ]
50
+ },
51
+ {
52
+ "cell_type": "code",
53
+ "execution_count": 17,
54
+ "metadata": {},
55
+ "outputs": [],
56
+ "source": [
57
+ "# Run the query and wait for it to complete\n",
58
+ "query_job = client.query(query)"
59
+ ]
60
+ },
61
+ {
62
+ "cell_type": "code",
63
+ "execution_count": 18,
64
+ "metadata": {},
65
+ "outputs": [
66
+ {
67
+ "ename": "Forbidden",
68
+ "evalue": "403 Access Denied: Table bigquery-public-data:serverfault.posts_questions: User does not have permission to query table bigquery-public-data:serverfault.posts_questions, or perhaps it does not exist in location US.",
69
+ "output_type": "error",
70
+ "traceback": [
71
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
72
+ "\u001b[0;31mForbidden\u001b[0m Traceback (most recent call last)",
73
+ "\u001b[1;32m/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb Cell 7\u001b[0m line \u001b[0;36m2\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb#W6sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39m# Iterate over the results and print them\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb#W6sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m \u001b[39mfor\u001b[39;49;00m row \u001b[39min\u001b[39;49;00m query_job:\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb#W6sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m \u001b[39m# print(f\"{row.name}: {row}\")\u001b[39;49;00m\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb#W6sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m \u001b[39mfor\u001b[39;49;00m k, v \u001b[39min\u001b[39;49;00m row\u001b[39m.\u001b[39;49mitems():\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/ag2435/repos/arXiv-agent/examples/data/bigquery.ipynb#W6sZmlsZQ%3D%3D?line=4'>5</a>\u001b[0m \u001b[39mprint\u001b[39;49m(\u001b[39mf\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m{\u001b[39;49;00mk\u001b[39m}\u001b[39;49;00m\u001b[39m: \u001b[39;49m\u001b[39m{\u001b[39;49;00mv\u001b[39m}\u001b[39;49;00m\u001b[39m\"\u001b[39;49m)\n",
74
+ "File \u001b[0;32m~/anaconda3/envs/arxiv-agent/lib/python3.12/site-packages/google/cloud/bigquery/job.py:2822\u001b[0m, in \u001b[0;36mQueryJob.__iter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 2821\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__iter__\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[0;32m-> 2822\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39miter\u001b[39m(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mresult())\n",
75
+ "File \u001b[0;32m~/anaconda3/envs/arxiv-agent/lib/python3.12/site-packages/google/cloud/bigquery/job.py:2762\u001b[0m, in \u001b[0;36mQueryJob.result\u001b[0;34m(self, timeout, retry)\u001b[0m\n\u001b[1;32m 2738\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mresult\u001b[39m(\u001b[39mself\u001b[39m, timeout\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m, retry\u001b[39m=\u001b[39mDEFAULT_RETRY):\n\u001b[1;32m 2739\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Start the job and wait for it to complete and get the result.\u001b[39;00m\n\u001b[1;32m 2740\u001b[0m \n\u001b[1;32m 2741\u001b[0m \u001b[39m :type timeout: float\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 2760\u001b[0m \u001b[39m not complete in the given timeout.\u001b[39;00m\n\u001b[1;32m 2761\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 2762\u001b[0m \u001b[39msuper\u001b[39;49m(QueryJob, \u001b[39mself\u001b[39;49m)\u001b[39m.\u001b[39;49mresult(timeout\u001b[39m=\u001b[39;49mtimeout)\n\u001b[1;32m 2763\u001b[0m \u001b[39m# Return an iterator instead of returning the job.\u001b[39;00m\n\u001b[1;32m 2764\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_query_results:\n",
76
+ "File \u001b[0;32m~/anaconda3/envs/arxiv-agent/lib/python3.12/site-packages/google/cloud/bigquery/job.py:703\u001b[0m, in \u001b[0;36m_AsyncJob.result\u001b[0;34m(self, timeout, retry)\u001b[0m\n\u001b[1;32m 701\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_begin(retry\u001b[39m=\u001b[39mretry)\n\u001b[1;32m 702\u001b[0m \u001b[39m# TODO: modify PollingFuture so it can pass a retry argument to done().\u001b[39;00m\n\u001b[0;32m--> 703\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39msuper\u001b[39;49m(_AsyncJob, \u001b[39mself\u001b[39;49m)\u001b[39m.\u001b[39;49mresult(timeout\u001b[39m=\u001b[39;49mtimeout)\n",
77
+ "File \u001b[0;32m~/anaconda3/envs/arxiv-agent/lib/python3.12/site-packages/google/api_core/future/polling.py:134\u001b[0m, in \u001b[0;36mPollingFuture.result\u001b[0;34m(self, timeout, retry)\u001b[0m\n\u001b[1;32m 129\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_blocking_poll(timeout\u001b[39m=\u001b[39mtimeout, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m 131\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_exception \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 132\u001b[0m \u001b[39m# pylint: disable=raising-bad-type\u001b[39;00m\n\u001b[1;32m 133\u001b[0m \u001b[39m# Pylint doesn't recognize that this is valid in this case.\u001b[39;00m\n\u001b[0;32m--> 134\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_exception\n\u001b[1;32m 136\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_result\n",
78
+ "\u001b[0;31mForbidden\u001b[0m: 403 Access Denied: Table bigquery-public-data:serverfault.posts_questions: User does not have permission to query table bigquery-public-data:serverfault.posts_questions, or perhaps it does not exist in location US."
79
+ ]
80
+ }
81
+ ],
82
+ "source": [
83
+ "# Iterate over the results and print them\n",
84
+ "for row in query_job:\n",
85
+ " # print(f\"{row.name}: {row}\")\n",
86
+ " for k, v in row.items():\n",
87
+ " print(f\"{k}: {v}\")\n",
88
+ " print()\n",
89
+ " "
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": 10,
95
+ "metadata": {},
96
+ "outputs": [],
97
+ "source": [
98
+ "df = query_job.to_dataframe()"
99
+ ]
100
+ },
101
+ {
102
+ "cell_type": "code",
103
+ "execution_count": 11,
104
+ "metadata": {},
105
+ "outputs": [
106
+ {
107
+ "data": {
108
+ "text/plain": [
109
+ "Index(['id', 'title', 'body', 'accepted_answer_id', 'answer_count',\n",
110
+ " 'comment_count', 'community_owned_date', 'creation_date',\n",
111
+ " 'favorite_count', 'last_activity_date', 'last_edit_date',\n",
112
+ " 'last_editor_display_name', 'last_editor_user_id', 'owner_display_name',\n",
113
+ " 'owner_user_id', 'parent_id', 'post_type_id', 'score', 'tags',\n",
114
+ " 'view_count'],\n",
115
+ " dtype='object')"
116
+ ]
117
+ },
118
+ "execution_count": 11,
119
+ "metadata": {},
120
+ "output_type": "execute_result"
121
+ }
122
+ ],
123
+ "source": [
124
+ "df.columns"
125
+ ]
126
+ },
127
+ {
128
+ "cell_type": "code",
129
+ "execution_count": 12,
130
+ "metadata": {},
131
+ "outputs": [
132
+ {
133
+ "data": {
134
+ "text/html": [
135
+ "<div>\n",
136
+ "<style scoped>\n",
137
+ " .dataframe tbody tr th:only-of-type {\n",
138
+ " vertical-align: middle;\n",
139
+ " }\n",
140
+ "\n",
141
+ " .dataframe tbody tr th {\n",
142
+ " vertical-align: top;\n",
143
+ " }\n",
144
+ "\n",
145
+ " .dataframe thead th {\n",
146
+ " text-align: right;\n",
147
+ " }\n",
148
+ "</style>\n",
149
+ "<table border=\"1\" class=\"dataframe\">\n",
150
+ " <thead>\n",
151
+ " <tr style=\"text-align: right;\">\n",
152
+ " <th></th>\n",
153
+ " <th>id</th>\n",
154
+ " <th>title</th>\n",
155
+ " <th>body</th>\n",
156
+ " <th>accepted_answer_id</th>\n",
157
+ " <th>answer_count</th>\n",
158
+ " <th>comment_count</th>\n",
159
+ " <th>community_owned_date</th>\n",
160
+ " <th>creation_date</th>\n",
161
+ " <th>favorite_count</th>\n",
162
+ " <th>last_activity_date</th>\n",
163
+ " <th>last_edit_date</th>\n",
164
+ " <th>last_editor_display_name</th>\n",
165
+ " <th>last_editor_user_id</th>\n",
166
+ " <th>owner_display_name</th>\n",
167
+ " <th>owner_user_id</th>\n",
168
+ " <th>parent_id</th>\n",
169
+ " <th>post_type_id</th>\n",
170
+ " <th>score</th>\n",
171
+ " <th>tags</th>\n",
172
+ " <th>view_count</th>\n",
173
+ " </tr>\n",
174
+ " </thead>\n",
175
+ " <tbody>\n",
176
+ " <tr>\n",
177
+ " <th>0</th>\n",
178
+ " <td>64177830</td>\n",
179
+ " <td>How to read to a certain point in python for e...</td>\n",
180
+ " <td>&lt;p&gt;I tried to read from every line until the &lt;...</td>\n",
181
+ " <td>NaN</td>\n",
182
+ " <td>2</td>\n",
183
+ " <td>0</td>\n",
184
+ " <td>None</td>\n",
185
+ " <td>2020-10-02 20:24:36.460000+00:00</td>\n",
186
+ " <td>NaN</td>\n",
187
+ " <td>2020-10-03 19:36:27.847000+00:00</td>\n",
188
+ " <td>2020-10-03 00:43:19.873000+00:00</td>\n",
189
+ " <td>None</td>\n",
190
+ " <td>7589636.0</td>\n",
191
+ " <td>user13798483</td>\n",
192
+ " <td>NaN</td>\n",
193
+ " <td>None</td>\n",
194
+ " <td>1</td>\n",
195
+ " <td>0</td>\n",
196
+ " <td>python|function|variables|line</td>\n",
197
+ " <td>256</td>\n",
198
+ " </tr>\n",
199
+ " <tr>\n",
200
+ " <th>1</th>\n",
201
+ " <td>64183547</td>\n",
202
+ " <td>How to use nested \"map\"</td>\n",
203
+ " <td>&lt;p&gt;I would like to map a json, based on some n...</td>\n",
204
+ " <td>64183941.0</td>\n",
205
+ " <td>2</td>\n",
206
+ " <td>0</td>\n",
207
+ " <td>None</td>\n",
208
+ " <td>2020-10-03 11:08:52.807000+00:00</td>\n",
209
+ " <td>NaN</td>\n",
210
+ " <td>2020-10-04 10:24:48.673000+00:00</td>\n",
211
+ " <td>NaT</td>\n",
212
+ " <td>None</td>\n",
213
+ " <td>NaN</td>\n",
214
+ " <td>None</td>\n",
215
+ " <td>11380853.0</td>\n",
216
+ " <td>None</td>\n",
217
+ " <td>1</td>\n",
218
+ " <td>2</td>\n",
219
+ " <td>dataweave|mulesoft</td>\n",
220
+ " <td>256</td>\n",
221
+ " </tr>\n",
222
+ " <tr>\n",
223
+ " <th>2</th>\n",
224
+ " <td>64220954</td>\n",
225
+ " <td>Azure DevOps Ephemeral agents not working</td>\n",
226
+ " <td>&lt;p&gt;I am trying to configure an Ephemeral agent...</td>\n",
227
+ " <td>64246902.0</td>\n",
228
+ " <td>2</td>\n",
229
+ " <td>0</td>\n",
230
+ " <td>None</td>\n",
231
+ " <td>2020-10-06 07:11:42.210000+00:00</td>\n",
232
+ " <td>1.0</td>\n",
233
+ " <td>2020-10-07 15:04:27.907000+00:00</td>\n",
234
+ " <td>NaT</td>\n",
235
+ " <td>None</td>\n",
236
+ " <td>NaN</td>\n",
237
+ " <td>None</td>\n",
238
+ " <td>5311841.0</td>\n",
239
+ " <td>None</td>\n",
240
+ " <td>1</td>\n",
241
+ " <td>0</td>\n",
242
+ " <td>azure|azure-devops|agent|azure-container-insta...</td>\n",
243
+ " <td>256</td>\n",
244
+ " </tr>\n",
245
+ " <tr>\n",
246
+ " <th>3</th>\n",
247
+ " <td>64228509</td>\n",
248
+ " <td>How do load value from DB only once in java</td>\n",
249
+ " <td>&lt;p&gt;I am using spring boot application and want...</td>\n",
250
+ " <td>NaN</td>\n",
251
+ " <td>1</td>\n",
252
+ " <td>0</td>\n",
253
+ " <td>None</td>\n",
254
+ " <td>2020-10-06 15:01:45.267000+00:00</td>\n",
255
+ " <td>NaN</td>\n",
256
+ " <td>2020-10-06 15:17:40.703000+00:00</td>\n",
257
+ " <td>2020-10-06 15:07:25.863000+00:00</td>\n",
258
+ " <td>None</td>\n",
259
+ " <td>14211936.0</td>\n",
260
+ " <td>None</td>\n",
261
+ " <td>14211936.0</td>\n",
262
+ " <td>None</td>\n",
263
+ " <td>1</td>\n",
264
+ " <td>0</td>\n",
265
+ " <td>java|spring|spring-boot</td>\n",
266
+ " <td>256</td>\n",
267
+ " </tr>\n",
268
+ " <tr>\n",
269
+ " <th>4</th>\n",
270
+ " <td>64232071</td>\n",
271
+ " <td>gh-pages script cannot commit .nojekyll to GitHub</td>\n",
272
+ " <td>&lt;p&gt;I have the following script in my &lt;code&gt;pac...</td>\n",
273
+ " <td>NaN</td>\n",
274
+ " <td>1</td>\n",
275
+ " <td>0</td>\n",
276
+ " <td>None</td>\n",
277
+ " <td>2020-10-06 18:49:10.107000+00:00</td>\n",
278
+ " <td>NaN</td>\n",
279
+ " <td>2021-06-08 11:51:34.657000+00:00</td>\n",
280
+ " <td>NaT</td>\n",
281
+ " <td>None</td>\n",
282
+ " <td>NaN</td>\n",
283
+ " <td>None</td>\n",
284
+ " <td>7738040.0</td>\n",
285
+ " <td>None</td>\n",
286
+ " <td>1</td>\n",
287
+ " <td>2</td>\n",
288
+ " <td>reactjs|git|next.js|github-pages</td>\n",
289
+ " <td>256</td>\n",
290
+ " </tr>\n",
291
+ " <tr>\n",
292
+ " <th>5</th>\n",
293
+ " <td>64237197</td>\n",
294
+ " <td>AttributeError: type object 'Graph' has no att...</td>\n",
295
+ " <td>&lt;p&gt;I am using python-igraph.&lt;/p&gt;\\n&lt;p&gt;Running t...</td>\n",
296
+ " <td>64237360.0</td>\n",
297
+ " <td>1</td>\n",
298
+ " <td>0</td>\n",
299
+ " <td>None</td>\n",
300
+ " <td>2020-10-07 04:26:20+00:00</td>\n",
301
+ " <td>NaN</td>\n",
302
+ " <td>2021-11-24 22:19:25.397000+00:00</td>\n",
303
+ " <td>2021-11-24 22:19:25.397000+00:00</td>\n",
304
+ " <td>None</td>\n",
305
+ " <td>695132.0</td>\n",
306
+ " <td>None</td>\n",
307
+ " <td>7418045.0</td>\n",
308
+ " <td>None</td>\n",
309
+ " <td>1</td>\n",
310
+ " <td>0</td>\n",
311
+ " <td>python|igraph</td>\n",
312
+ " <td>256</td>\n",
313
+ " </tr>\n",
314
+ " <tr>\n",
315
+ " <th>6</th>\n",
316
+ " <td>64244371</td>\n",
317
+ " <td>IAR Compiler Linker Error [Li009]: _CPP_Except...</td>\n",
318
+ " <td>&lt;p&gt;I have a project which compiles with the IA...</td>\n",
319
+ " <td>64251998.0</td>\n",
320
+ " <td>1</td>\n",
321
+ " <td>0</td>\n",
322
+ " <td>None</td>\n",
323
+ " <td>2020-10-07 12:50:38.073000+00:00</td>\n",
324
+ " <td>NaN</td>\n",
325
+ " <td>2020-10-07 20:41:03.237000+00:00</td>\n",
326
+ " <td>2020-10-07 13:01:16.020000+00:00</td>\n",
327
+ " <td>None</td>\n",
328
+ " <td>14367166.0</td>\n",
329
+ " <td>None</td>\n",
330
+ " <td>14367166.0</td>\n",
331
+ " <td>None</td>\n",
332
+ " <td>1</td>\n",
333
+ " <td>0</td>\n",
334
+ " <td>exception|linker|embedded|stm32|iar</td>\n",
335
+ " <td>256</td>\n",
336
+ " </tr>\n",
337
+ " <tr>\n",
338
+ " <th>7</th>\n",
339
+ " <td>64256016</td>\n",
340
+ " <td>Nativescript gestures not working with vuejs</td>\n",
341
+ " <td>&lt;p&gt;How to use them? Docs are not clear about v...</td>\n",
342
+ " <td>NaN</td>\n",
343
+ " <td>1</td>\n",
344
+ " <td>0</td>\n",
345
+ " <td>None</td>\n",
346
+ " <td>2020-10-08 04:55:16.917000+00:00</td>\n",
347
+ " <td>NaN</td>\n",
348
+ " <td>2020-10-08 06:31:26.930000+00:00</td>\n",
349
+ " <td>NaT</td>\n",
350
+ " <td>None</td>\n",
351
+ " <td>NaN</td>\n",
352
+ " <td>None</td>\n",
353
+ " <td>4254220.0</td>\n",
354
+ " <td>None</td>\n",
355
+ " <td>1</td>\n",
356
+ " <td>0</td>\n",
357
+ " <td>nativescript|nativescript-vue</td>\n",
358
+ " <td>256</td>\n",
359
+ " </tr>\n",
360
+ " <tr>\n",
361
+ " <th>8</th>\n",
362
+ " <td>64262142</td>\n",
363
+ " <td>Instantiate and set to parent of a sub gameObject</td>\n",
364
+ " <td>&lt;p&gt;I have a multi level gameObject hierarchy t...</td>\n",
365
+ " <td>64263996.0</td>\n",
366
+ " <td>2</td>\n",
367
+ " <td>0</td>\n",
368
+ " <td>None</td>\n",
369
+ " <td>2020-10-08 12:04:39.540000+00:00</td>\n",
370
+ " <td>NaN</td>\n",
371
+ " <td>2020-10-08 14:16:11.620000+00:00</td>\n",
372
+ " <td>NaT</td>\n",
373
+ " <td>None</td>\n",
374
+ " <td>NaN</td>\n",
375
+ " <td>None</td>\n",
376
+ " <td>14260342.0</td>\n",
377
+ " <td>None</td>\n",
378
+ " <td>1</td>\n",
379
+ " <td>0</td>\n",
380
+ " <td>c#|unity3d</td>\n",
381
+ " <td>256</td>\n",
382
+ " </tr>\n",
383
+ " <tr>\n",
384
+ " <th>9</th>\n",
385
+ " <td>64263183</td>\n",
386
+ " <td>SLIM PUT-Request CORS Header missing</td>\n",
387
+ " <td>&lt;p&gt;I've tried to set up a Angular App with SLI...</td>\n",
388
+ " <td>NaN</td>\n",
389
+ " <td>1</td>\n",
390
+ " <td>0</td>\n",
391
+ " <td>None</td>\n",
392
+ " <td>2020-10-08 13:06:02.593000+00:00</td>\n",
393
+ " <td>NaN</td>\n",
394
+ " <td>2020-10-08 13:24:33.893000+00:00</td>\n",
395
+ " <td>NaT</td>\n",
396
+ " <td>None</td>\n",
397
+ " <td>NaN</td>\n",
398
+ " <td>None</td>\n",
399
+ " <td>8518867.0</td>\n",
400
+ " <td>None</td>\n",
401
+ " <td>1</td>\n",
402
+ " <td>0</td>\n",
403
+ " <td>php|angular|slim|slim-4</td>\n",
404
+ " <td>256</td>\n",
405
+ " </tr>\n",
406
+ " </tbody>\n",
407
+ "</table>\n",
408
+ "</div>"
409
+ ],
410
+ "text/plain": [
411
+ " id title \\\n",
412
+ "0 64177830 How to read to a certain point in python for e... \n",
413
+ "1 64183547 How to use nested \"map\" \n",
414
+ "2 64220954 Azure DevOps Ephemeral agents not working \n",
415
+ "3 64228509 How do load value from DB only once in java \n",
416
+ "4 64232071 gh-pages script cannot commit .nojekyll to GitHub \n",
417
+ "5 64237197 AttributeError: type object 'Graph' has no att... \n",
418
+ "6 64244371 IAR Compiler Linker Error [Li009]: _CPP_Except... \n",
419
+ "7 64256016 Nativescript gestures not working with vuejs \n",
420
+ "8 64262142 Instantiate and set to parent of a sub gameObject \n",
421
+ "9 64263183 SLIM PUT-Request CORS Header missing \n",
422
+ "\n",
423
+ " body accepted_answer_id \\\n",
424
+ "0 <p>I tried to read from every line until the <... NaN \n",
425
+ "1 <p>I would like to map a json, based on some n... 64183941.0 \n",
426
+ "2 <p>I am trying to configure an Ephemeral agent... 64246902.0 \n",
427
+ "3 <p>I am using spring boot application and want... NaN \n",
428
+ "4 <p>I have the following script in my <code>pac... NaN \n",
429
+ "5 <p>I am using python-igraph.</p>\\n<p>Running t... 64237360.0 \n",
430
+ "6 <p>I have a project which compiles with the IA... 64251998.0 \n",
431
+ "7 <p>How to use them? Docs are not clear about v... NaN \n",
432
+ "8 <p>I have a multi level gameObject hierarchy t... 64263996.0 \n",
433
+ "9 <p>I've tried to set up a Angular App with SLI... NaN \n",
434
+ "\n",
435
+ " answer_count comment_count community_owned_date \\\n",
436
+ "0 2 0 None \n",
437
+ "1 2 0 None \n",
438
+ "2 2 0 None \n",
439
+ "3 1 0 None \n",
440
+ "4 1 0 None \n",
441
+ "5 1 0 None \n",
442
+ "6 1 0 None \n",
443
+ "7 1 0 None \n",
444
+ "8 2 0 None \n",
445
+ "9 1 0 None \n",
446
+ "\n",
447
+ " creation_date favorite_count \\\n",
448
+ "0 2020-10-02 20:24:36.460000+00:00 NaN \n",
449
+ "1 2020-10-03 11:08:52.807000+00:00 NaN \n",
450
+ "2 2020-10-06 07:11:42.210000+00:00 1.0 \n",
451
+ "3 2020-10-06 15:01:45.267000+00:00 NaN \n",
452
+ "4 2020-10-06 18:49:10.107000+00:00 NaN \n",
453
+ "5 2020-10-07 04:26:20+00:00 NaN \n",
454
+ "6 2020-10-07 12:50:38.073000+00:00 NaN \n",
455
+ "7 2020-10-08 04:55:16.917000+00:00 NaN \n",
456
+ "8 2020-10-08 12:04:39.540000+00:00 NaN \n",
457
+ "9 2020-10-08 13:06:02.593000+00:00 NaN \n",
458
+ "\n",
459
+ " last_activity_date last_edit_date \\\n",
460
+ "0 2020-10-03 19:36:27.847000+00:00 2020-10-03 00:43:19.873000+00:00 \n",
461
+ "1 2020-10-04 10:24:48.673000+00:00 NaT \n",
462
+ "2 2020-10-07 15:04:27.907000+00:00 NaT \n",
463
+ "3 2020-10-06 15:17:40.703000+00:00 2020-10-06 15:07:25.863000+00:00 \n",
464
+ "4 2021-06-08 11:51:34.657000+00:00 NaT \n",
465
+ "5 2021-11-24 22:19:25.397000+00:00 2021-11-24 22:19:25.397000+00:00 \n",
466
+ "6 2020-10-07 20:41:03.237000+00:00 2020-10-07 13:01:16.020000+00:00 \n",
467
+ "7 2020-10-08 06:31:26.930000+00:00 NaT \n",
468
+ "8 2020-10-08 14:16:11.620000+00:00 NaT \n",
469
+ "9 2020-10-08 13:24:33.893000+00:00 NaT \n",
470
+ "\n",
471
+ " last_editor_display_name last_editor_user_id owner_display_name \\\n",
472
+ "0 None 7589636.0 user13798483 \n",
473
+ "1 None NaN None \n",
474
+ "2 None NaN None \n",
475
+ "3 None 14211936.0 None \n",
476
+ "4 None NaN None \n",
477
+ "5 None 695132.0 None \n",
478
+ "6 None 14367166.0 None \n",
479
+ "7 None NaN None \n",
480
+ "8 None NaN None \n",
481
+ "9 None NaN None \n",
482
+ "\n",
483
+ " owner_user_id parent_id post_type_id score \\\n",
484
+ "0 NaN None 1 0 \n",
485
+ "1 11380853.0 None 1 2 \n",
486
+ "2 5311841.0 None 1 0 \n",
487
+ "3 14211936.0 None 1 0 \n",
488
+ "4 7738040.0 None 1 2 \n",
489
+ "5 7418045.0 None 1 0 \n",
490
+ "6 14367166.0 None 1 0 \n",
491
+ "7 4254220.0 None 1 0 \n",
492
+ "8 14260342.0 None 1 0 \n",
493
+ "9 8518867.0 None 1 0 \n",
494
+ "\n",
495
+ " tags view_count \n",
496
+ "0 python|function|variables|line 256 \n",
497
+ "1 dataweave|mulesoft 256 \n",
498
+ "2 azure|azure-devops|agent|azure-container-insta... 256 \n",
499
+ "3 java|spring|spring-boot 256 \n",
500
+ "4 reactjs|git|next.js|github-pages 256 \n",
501
+ "5 python|igraph 256 \n",
502
+ "6 exception|linker|embedded|stm32|iar 256 \n",
503
+ "7 nativescript|nativescript-vue 256 \n",
504
+ "8 c#|unity3d 256 \n",
505
+ "9 php|angular|slim|slim-4 256 "
506
+ ]
507
+ },
508
+ "execution_count": 12,
509
+ "metadata": {},
510
+ "output_type": "execute_result"
511
+ }
512
+ ],
513
+ "source": [
514
+ "df"
515
+ ]
516
+ },
517
+ {
518
+ "cell_type": "markdown",
519
+ "metadata": {},
520
+ "source": [
521
+ "## Count questions"
522
+ ]
523
+ },
524
+ {
525
+ "cell_type": "code",
526
+ "execution_count": 13,
527
+ "metadata": {},
528
+ "outputs": [],
529
+ "source": [
530
+ "# write a sql query that counts the number of rows in the stackoverflow posts_questions table\n",
531
+ "query = \"\"\"\n",
532
+ " SELECT COUNT(*)\n",
533
+ " FROM `bigquery-public-data.stackoverflow.posts_questions`\n",
534
+ "\"\"\""
535
+ ]
536
+ },
537
+ {
538
+ "cell_type": "code",
539
+ "execution_count": 14,
540
+ "metadata": {},
541
+ "outputs": [],
542
+ "source": [
543
+ "query_job = client.query(query)"
544
+ ]
545
+ },
546
+ {
547
+ "cell_type": "code",
548
+ "execution_count": 15,
549
+ "metadata": {},
550
+ "outputs": [
551
+ {
552
+ "data": {
553
+ "text/html": [
554
+ "<div>\n",
555
+ "<style scoped>\n",
556
+ " .dataframe tbody tr th:only-of-type {\n",
557
+ " vertical-align: middle;\n",
558
+ " }\n",
559
+ "\n",
560
+ " .dataframe tbody tr th {\n",
561
+ " vertical-align: top;\n",
562
+ " }\n",
563
+ "\n",
564
+ " .dataframe thead th {\n",
565
+ " text-align: right;\n",
566
+ " }\n",
567
+ "</style>\n",
568
+ "<table border=\"1\" class=\"dataframe\">\n",
569
+ " <thead>\n",
570
+ " <tr style=\"text-align: right;\">\n",
571
+ " <th></th>\n",
572
+ " <th>f0_</th>\n",
573
+ " </tr>\n",
574
+ " </thead>\n",
575
+ " <tbody>\n",
576
+ " <tr>\n",
577
+ " <th>0</th>\n",
578
+ " <td>23020127</td>\n",
579
+ " </tr>\n",
580
+ " </tbody>\n",
581
+ "</table>\n",
582
+ "</div>"
583
+ ],
584
+ "text/plain": [
585
+ " f0_\n",
586
+ "0 23020127"
587
+ ]
588
+ },
589
+ "execution_count": 15,
590
+ "metadata": {},
591
+ "output_type": "execute_result"
592
+ }
593
+ ],
594
+ "source": [
595
+ "query_job.to_dataframe()"
596
+ ]
597
+ },
598
+ {
599
+ "cell_type": "markdown",
600
+ "metadata": {},
601
+ "source": [
602
+ "## Pattern matching answers"
603
+ ]
604
+ },
605
+ {
606
+ "cell_type": "code",
607
+ "execution_count": 22,
608
+ "metadata": {},
609
+ "outputs": [],
610
+ "source": [
611
+ "query = \"\"\"\n",
612
+ " SELECT *\n",
613
+ " FROM `bigquery-public-data.stackoverflow.posts_answers`\n",
614
+ " WHERE post_type_id = 2\n",
615
+ " AND BODY LIKE '%arxiv%'\n",
616
+ " LIMIT 1000\n",
617
+ "\"\"\""
618
+ ]
619
+ },
620
+ {
621
+ "cell_type": "code",
622
+ "execution_count": 23,
623
+ "metadata": {},
624
+ "outputs": [],
625
+ "source": [
626
+ "query_job = client.query(query)"
627
+ ]
628
+ },
629
+ {
630
+ "cell_type": "code",
631
+ "execution_count": 24,
632
+ "metadata": {},
633
+ "outputs": [
634
+ {
635
+ "data": {
636
+ "text/html": [
637
+ "<div>\n",
638
+ "<style scoped>\n",
639
+ " .dataframe tbody tr th:only-of-type {\n",
640
+ " vertical-align: middle;\n",
641
+ " }\n",
642
+ "\n",
643
+ " .dataframe tbody tr th {\n",
644
+ " vertical-align: top;\n",
645
+ " }\n",
646
+ "\n",
647
+ " .dataframe thead th {\n",
648
+ " text-align: right;\n",
649
+ " }\n",
650
+ "</style>\n",
651
+ "<table border=\"1\" class=\"dataframe\">\n",
652
+ " <thead>\n",
653
+ " <tr style=\"text-align: right;\">\n",
654
+ " <th></th>\n",
655
+ " <th>id</th>\n",
656
+ " <th>title</th>\n",
657
+ " <th>body</th>\n",
658
+ " <th>accepted_answer_id</th>\n",
659
+ " <th>answer_count</th>\n",
660
+ " <th>comment_count</th>\n",
661
+ " <th>community_owned_date</th>\n",
662
+ " <th>creation_date</th>\n",
663
+ " <th>favorite_count</th>\n",
664
+ " <th>last_activity_date</th>\n",
665
+ " <th>last_edit_date</th>\n",
666
+ " <th>last_editor_display_name</th>\n",
667
+ " <th>last_editor_user_id</th>\n",
668
+ " <th>owner_display_name</th>\n",
669
+ " <th>owner_user_id</th>\n",
670
+ " <th>parent_id</th>\n",
671
+ " <th>post_type_id</th>\n",
672
+ " <th>score</th>\n",
673
+ " <th>tags</th>\n",
674
+ " <th>view_count</th>\n",
675
+ " </tr>\n",
676
+ " </thead>\n",
677
+ " <tbody>\n",
678
+ " <tr>\n",
679
+ " <th>0</th>\n",
680
+ " <td>4635560</td>\n",
681
+ " <td>None</td>\n",
682
+ " <td>&lt;p&gt;Asking the question in such a general way d...</td>\n",
683
+ " <td>None</td>\n",
684
+ " <td>None</td>\n",
685
+ " <td>0</td>\n",
686
+ " <td>NaT</td>\n",
687
+ " <td>2011-01-08 18:54:26.003000+00:00</td>\n",
688
+ " <td>None</td>\n",
689
+ " <td>2011-01-09 09:22:47.240000+00:00</td>\n",
690
+ " <td>2011-01-09 09:22:47.240000+00:00</td>\n",
691
+ " <td>None</td>\n",
692
+ " <td>487781.0</td>\n",
693
+ " <td>None</td>\n",
694
+ " <td>487781.0</td>\n",
695
+ " <td>4635254</td>\n",
696
+ " <td>2</td>\n",
697
+ " <td>5</td>\n",
698
+ " <td>None</td>\n",
699
+ " <td>None</td>\n",
700
+ " </tr>\n",
701
+ " <tr>\n",
702
+ " <th>1</th>\n",
703
+ " <td>4509603</td>\n",
704
+ " <td>None</td>\n",
705
+ " <td>&lt;p&gt;You're right to point out that the adjacenc...</td>\n",
706
+ " <td>None</td>\n",
707
+ " <td>None</td>\n",
708
+ " <td>1</td>\n",
709
+ " <td>NaT</td>\n",
710
+ " <td>2010-12-22 13:25:12.920000+00:00</td>\n",
711
+ " <td>None</td>\n",
712
+ " <td>2010-12-22 13:25:12.920000+00:00</td>\n",
713
+ " <td>NaT</td>\n",
714
+ " <td>None</td>\n",
715
+ " <td>NaN</td>\n",
716
+ " <td>None</td>\n",
717
+ " <td>68063.0</td>\n",
718
+ " <td>4509270</td>\n",
719
+ " <td>2</td>\n",
720
+ " <td>5</td>\n",
721
+ " <td>None</td>\n",
722
+ " <td>None</td>\n",
723
+ " </tr>\n",
724
+ " <tr>\n",
725
+ " <th>2</th>\n",
726
+ " <td>4617053</td>\n",
727
+ " <td>None</td>\n",
728
+ " <td>&lt;p&gt;There's a paper titled &lt;a href=\"http://arxi...</td>\n",
729
+ " <td>None</td>\n",
730
+ " <td>None</td>\n",
731
+ " <td>1</td>\n",
732
+ " <td>NaT</td>\n",
733
+ " <td>2011-01-06 16:17:47.360000+00:00</td>\n",
734
+ " <td>None</td>\n",
735
+ " <td>2011-01-06 16:17:47.360000+00:00</td>\n",
736
+ " <td>NaT</td>\n",
737
+ " <td>None</td>\n",
738
+ " <td>NaN</td>\n",
739
+ " <td>None</td>\n",
740
+ " <td>260307.0</td>\n",
741
+ " <td>4600258</td>\n",
742
+ " <td>2</td>\n",
743
+ " <td>8</td>\n",
744
+ " <td>None</td>\n",
745
+ " <td>None</td>\n",
746
+ " </tr>\n",
747
+ " <tr>\n",
748
+ " <th>3</th>\n",
749
+ " <td>4988447</td>\n",
750
+ " <td>None</td>\n",
751
+ " <td>&lt;p&gt;Is this the type of thing you are looking f...</td>\n",
752
+ " <td>None</td>\n",
753
+ " <td>None</td>\n",
754
+ " <td>3</td>\n",
755
+ " <td>NaT</td>\n",
756
+ " <td>2011-02-14 02:51:38+00:00</td>\n",
757
+ " <td>None</td>\n",
758
+ " <td>2011-02-14 03:02:24.360000+00:00</td>\n",
759
+ " <td>2011-02-14 03:02:24.360000+00:00</td>\n",
760
+ " <td>None</td>\n",
761
+ " <td>421225.0</td>\n",
762
+ " <td>None</td>\n",
763
+ " <td>421225.0</td>\n",
764
+ " <td>4988323</td>\n",
765
+ " <td>2</td>\n",
766
+ " <td>2</td>\n",
767
+ " <td>None</td>\n",
768
+ " <td>None</td>\n",
769
+ " </tr>\n",
770
+ " <tr>\n",
771
+ " <th>4</th>\n",
772
+ " <td>7842</td>\n",
773
+ " <td>None</td>\n",
774
+ " <td>&lt;p&gt;You can do this in two lines in python with...</td>\n",
775
+ " <td>None</td>\n",
776
+ " <td>None</td>\n",
777
+ " <td>1</td>\n",
778
+ " <td>NaT</td>\n",
779
+ " <td>2008-08-11 14:47:31.227000+00:00</td>\n",
780
+ " <td>None</td>\n",
781
+ " <td>2020-07-27 01:15:48.273000+00:00</td>\n",
782
+ " <td>2020-07-27 01:15:48.273000+00:00</td>\n",
783
+ " <td>None</td>\n",
784
+ " <td>6800539.0</td>\n",
785
+ " <td>Pall Melsted</td>\n",
786
+ " <td>NaN</td>\n",
787
+ " <td>826</td>\n",
788
+ " <td>2</td>\n",
789
+ " <td>2</td>\n",
790
+ " <td>None</td>\n",
791
+ " <td>None</td>\n",
792
+ " </tr>\n",
793
+ " <tr>\n",
794
+ " <th>...</th>\n",
795
+ " <td>...</td>\n",
796
+ " <td>...</td>\n",
797
+ " <td>...</td>\n",
798
+ " <td>...</td>\n",
799
+ " <td>...</td>\n",
800
+ " <td>...</td>\n",
801
+ " <td>...</td>\n",
802
+ " <td>...</td>\n",
803
+ " <td>...</td>\n",
804
+ " <td>...</td>\n",
805
+ " <td>...</td>\n",
806
+ " <td>...</td>\n",
807
+ " <td>...</td>\n",
808
+ " <td>...</td>\n",
809
+ " <td>...</td>\n",
810
+ " <td>...</td>\n",
811
+ " <td>...</td>\n",
812
+ " <td>...</td>\n",
813
+ " <td>...</td>\n",
814
+ " <td>...</td>\n",
815
+ " </tr>\n",
816
+ " <tr>\n",
817
+ " <th>995</th>\n",
818
+ " <td>50711443</td>\n",
819
+ " <td>None</td>\n",
820
+ " <td>&lt;p&gt;If you want to classify the image then you ...</td>\n",
821
+ " <td>None</td>\n",
822
+ " <td>None</td>\n",
823
+ " <td>0</td>\n",
824
+ " <td>NaT</td>\n",
825
+ " <td>2018-06-06 02:27:58.530000+00:00</td>\n",
826
+ " <td>None</td>\n",
827
+ " <td>2018-06-06 02:34:47.867000+00:00</td>\n",
828
+ " <td>2018-06-06 02:34:47.867000+00:00</td>\n",
829
+ " <td>None</td>\n",
830
+ " <td>7984359.0</td>\n",
831
+ " <td>None</td>\n",
832
+ " <td>7984359.0</td>\n",
833
+ " <td>50710556</td>\n",
834
+ " <td>2</td>\n",
835
+ " <td>1</td>\n",
836
+ " <td>None</td>\n",
837
+ " <td>None</td>\n",
838
+ " </tr>\n",
839
+ " <tr>\n",
840
+ " <th>996</th>\n",
841
+ " <td>50884034</td>\n",
842
+ " <td>None</td>\n",
843
+ " <td>&lt;p&gt;Unfortunately, batch size is a hyper parame...</td>\n",
844
+ " <td>None</td>\n",
845
+ " <td>None</td>\n",
846
+ " <td>0</td>\n",
847
+ " <td>NaT</td>\n",
848
+ " <td>2018-06-16 00:14:37.153000+00:00</td>\n",
849
+ " <td>None</td>\n",
850
+ " <td>2018-06-16 00:14:37.153000+00:00</td>\n",
851
+ " <td>NaT</td>\n",
852
+ " <td>None</td>\n",
853
+ " <td>NaN</td>\n",
854
+ " <td>None</td>\n",
855
+ " <td>1574073.0</td>\n",
856
+ " <td>50883917</td>\n",
857
+ " <td>2</td>\n",
858
+ " <td>1</td>\n",
859
+ " <td>None</td>\n",
860
+ " <td>None</td>\n",
861
+ " </tr>\n",
862
+ " <tr>\n",
863
+ " <th>997</th>\n",
864
+ " <td>50936084</td>\n",
865
+ " <td>None</td>\n",
866
+ " <td>&lt;p&gt;You want object detection and segmentation....</td>\n",
867
+ " <td>None</td>\n",
868
+ " <td>None</td>\n",
869
+ " <td>0</td>\n",
870
+ " <td>NaT</td>\n",
871
+ " <td>2018-06-19 20:01:01.307000+00:00</td>\n",
872
+ " <td>None</td>\n",
873
+ " <td>2018-06-19 20:01:01.307000+00:00</td>\n",
874
+ " <td>NaT</td>\n",
875
+ " <td>None</td>\n",
876
+ " <td>NaN</td>\n",
877
+ " <td>None</td>\n",
878
+ " <td>2286337.0</td>\n",
879
+ " <td>50935297</td>\n",
880
+ " <td>2</td>\n",
881
+ " <td>1</td>\n",
882
+ " <td>None</td>\n",
883
+ " <td>None</td>\n",
884
+ " </tr>\n",
885
+ " <tr>\n",
886
+ " <th>998</th>\n",
887
+ " <td>50958287</td>\n",
888
+ " <td>None</td>\n",
889
+ " <td>&lt;p&gt;There is a technique where you can write yo...</td>\n",
890
+ " <td>None</td>\n",
891
+ " <td>None</td>\n",
892
+ " <td>0</td>\n",
893
+ " <td>NaT</td>\n",
894
+ " <td>2018-06-20 23:13:01.947000+00:00</td>\n",
895
+ " <td>None</td>\n",
896
+ " <td>2018-06-20 23:13:01.947000+00:00</td>\n",
897
+ " <td>NaT</td>\n",
898
+ " <td>None</td>\n",
899
+ " <td>NaN</td>\n",
900
+ " <td>None</td>\n",
901
+ " <td>7900077.0</td>\n",
902
+ " <td>29994694</td>\n",
903
+ " <td>2</td>\n",
904
+ " <td>1</td>\n",
905
+ " <td>None</td>\n",
906
+ " <td>None</td>\n",
907
+ " </tr>\n",
908
+ " <tr>\n",
909
+ " <th>999</th>\n",
910
+ " <td>50780869</td>\n",
911
+ " <td>None</td>\n",
912
+ " <td>&lt;p&gt;Both current answers are wrong in that they...</td>\n",
913
+ " <td>None</td>\n",
914
+ " <td>None</td>\n",
915
+ " <td>0</td>\n",
916
+ " <td>NaT</td>\n",
917
+ " <td>2018-06-10 05:37:44.840000+00:00</td>\n",
918
+ " <td>None</td>\n",
919
+ " <td>2018-06-15 10:24:02.077000+00:00</td>\n",
920
+ " <td>2018-06-15 10:24:02.077000+00:00</td>\n",
921
+ " <td>None</td>\n",
922
+ " <td>2366315.0</td>\n",
923
+ " <td>None</td>\n",
924
+ " <td>2366315.0</td>\n",
925
+ " <td>36570904</td>\n",
926
+ " <td>2</td>\n",
927
+ " <td>2</td>\n",
928
+ " <td>None</td>\n",
929
+ " <td>None</td>\n",
930
+ " </tr>\n",
931
+ " </tbody>\n",
932
+ "</table>\n",
933
+ "<p>1000 rows × 20 columns</p>\n",
934
+ "</div>"
935
+ ],
936
+ "text/plain": [
937
+ " id title body \\\n",
938
+ "0 4635560 None <p>Asking the question in such a general way d... \n",
939
+ "1 4509603 None <p>You're right to point out that the adjacenc... \n",
940
+ "2 4617053 None <p>There's a paper titled <a href=\"http://arxi... \n",
941
+ "3 4988447 None <p>Is this the type of thing you are looking f... \n",
942
+ "4 7842 None <p>You can do this in two lines in python with... \n",
943
+ ".. ... ... ... \n",
944
+ "995 50711443 None <p>If you want to classify the image then you ... \n",
945
+ "996 50884034 None <p>Unfortunately, batch size is a hyper parame... \n",
946
+ "997 50936084 None <p>You want object detection and segmentation.... \n",
947
+ "998 50958287 None <p>There is a technique where you can write yo... \n",
948
+ "999 50780869 None <p>Both current answers are wrong in that they... \n",
949
+ "\n",
950
+ " accepted_answer_id answer_count comment_count community_owned_date \\\n",
951
+ "0 None None 0 NaT \n",
952
+ "1 None None 1 NaT \n",
953
+ "2 None None 1 NaT \n",
954
+ "3 None None 3 NaT \n",
955
+ "4 None None 1 NaT \n",
956
+ ".. ... ... ... ... \n",
957
+ "995 None None 0 NaT \n",
958
+ "996 None None 0 NaT \n",
959
+ "997 None None 0 NaT \n",
960
+ "998 None None 0 NaT \n",
961
+ "999 None None 0 NaT \n",
962
+ "\n",
963
+ " creation_date favorite_count \\\n",
964
+ "0 2011-01-08 18:54:26.003000+00:00 None \n",
965
+ "1 2010-12-22 13:25:12.920000+00:00 None \n",
966
+ "2 2011-01-06 16:17:47.360000+00:00 None \n",
967
+ "3 2011-02-14 02:51:38+00:00 None \n",
968
+ "4 2008-08-11 14:47:31.227000+00:00 None \n",
969
+ ".. ... ... \n",
970
+ "995 2018-06-06 02:27:58.530000+00:00 None \n",
971
+ "996 2018-06-16 00:14:37.153000+00:00 None \n",
972
+ "997 2018-06-19 20:01:01.307000+00:00 None \n",
973
+ "998 2018-06-20 23:13:01.947000+00:00 None \n",
974
+ "999 2018-06-10 05:37:44.840000+00:00 None \n",
975
+ "\n",
976
+ " last_activity_date last_edit_date \\\n",
977
+ "0 2011-01-09 09:22:47.240000+00:00 2011-01-09 09:22:47.240000+00:00 \n",
978
+ "1 2010-12-22 13:25:12.920000+00:00 NaT \n",
979
+ "2 2011-01-06 16:17:47.360000+00:00 NaT \n",
980
+ "3 2011-02-14 03:02:24.360000+00:00 2011-02-14 03:02:24.360000+00:00 \n",
981
+ "4 2020-07-27 01:15:48.273000+00:00 2020-07-27 01:15:48.273000+00:00 \n",
982
+ ".. ... ... \n",
983
+ "995 2018-06-06 02:34:47.867000+00:00 2018-06-06 02:34:47.867000+00:00 \n",
984
+ "996 2018-06-16 00:14:37.153000+00:00 NaT \n",
985
+ "997 2018-06-19 20:01:01.307000+00:00 NaT \n",
986
+ "998 2018-06-20 23:13:01.947000+00:00 NaT \n",
987
+ "999 2018-06-15 10:24:02.077000+00:00 2018-06-15 10:24:02.077000+00:00 \n",
988
+ "\n",
989
+ " last_editor_display_name last_editor_user_id owner_display_name \\\n",
990
+ "0 None 487781.0 None \n",
991
+ "1 None NaN None \n",
992
+ "2 None NaN None \n",
993
+ "3 None 421225.0 None \n",
994
+ "4 None 6800539.0 Pall Melsted \n",
995
+ ".. ... ... ... \n",
996
+ "995 None 7984359.0 None \n",
997
+ "996 None NaN None \n",
998
+ "997 None NaN None \n",
999
+ "998 None NaN None \n",
1000
+ "999 None 2366315.0 None \n",
1001
+ "\n",
1002
+ " owner_user_id parent_id post_type_id score tags view_count \n",
1003
+ "0 487781.0 4635254 2 5 None None \n",
1004
+ "1 68063.0 4509270 2 5 None None \n",
1005
+ "2 260307.0 4600258 2 8 None None \n",
1006
+ "3 421225.0 4988323 2 2 None None \n",
1007
+ "4 NaN 826 2 2 None None \n",
1008
+ ".. ... ... ... ... ... ... \n",
1009
+ "995 7984359.0 50710556 2 1 None None \n",
1010
+ "996 1574073.0 50883917 2 1 None None \n",
1011
+ "997 2286337.0 50935297 2 1 None None \n",
1012
+ "998 7900077.0 29994694 2 1 None None \n",
1013
+ "999 2366315.0 36570904 2 2 None None \n",
1014
+ "\n",
1015
+ "[1000 rows x 20 columns]"
1016
+ ]
1017
+ },
1018
+ "execution_count": 24,
1019
+ "metadata": {},
1020
+ "output_type": "execute_result"
1021
+ }
1022
+ ],
1023
+ "source": [
1024
+ "query_job.to_dataframe()"
1025
+ ]
1026
+ },
1027
+ {
1028
+ "cell_type": "code",
1029
+ "execution_count": 37,
1030
+ "metadata": {},
1031
+ "outputs": [],
1032
+ "source": [
1033
+ "query_job = client.query(\"\"\"\n",
1034
+ "CREATE TEMP TABLE answers AS\n",
1035
+ "SELECT *\n",
1036
+ "FROM bigquery-public-data.stackoverflow.posts_answers\n",
1037
+ "WHERE LOWER(Body) LIKE '%arxiv%';\n",
1038
+ "\n",
1039
+ "CREATE TEMPORARY TABLE questions AS\n",
1040
+ "SELECT *\n",
1041
+ "FROM bigquery-public-data.stackoverflow.posts_questions;\n",
1042
+ "\n",
1043
+ "SELECT *\n",
1044
+ "FROM answers\n",
1045
+ "JOIN questions ON questions.id = answers.parent_id;\n",
1046
+ "\"\"\")"
1047
+ ]
1048
+ },
1049
+ {
1050
+ "cell_type": "code",
1051
+ "execution_count": 54,
1052
+ "metadata": {},
1053
+ "outputs": [],
1054
+ "source": [
1055
+ "def to_dict(row):\n",
1056
+ " d = {}\n",
1057
+ " for k,v in row.items():\n",
1058
+ " if k[-2:] == '_1':\n",
1059
+ " new_k = 'q_' + k[:-2]\n",
1060
+ " else:\n",
1061
+ " new_k = 'a_' + k\n",
1062
+ " d[new_k] = v\n",
1063
+ " return d"
1064
+ ]
1065
+ },
1066
+ {
1067
+ "cell_type": "code",
1068
+ "execution_count": 55,
1069
+ "metadata": {},
1070
+ "outputs": [],
1071
+ "source": [
1072
+ "results = [to_dict(row) for row in query_job]"
1073
+ ]
1074
+ },
1075
+ {
1076
+ "cell_type": "code",
1077
+ "execution_count": 56,
1078
+ "metadata": {},
1079
+ "outputs": [],
1080
+ "source": [
1081
+ "df_qa = pd.DataFrame(results)"
1082
+ ]
1083
+ },
1084
+ {
1085
+ "cell_type": "code",
1086
+ "execution_count": 57,
1087
+ "metadata": {},
1088
+ "outputs": [
1089
+ {
1090
+ "data": {
1091
+ "text/html": [
1092
+ "<div>\n",
1093
+ "<style scoped>\n",
1094
+ " .dataframe tbody tr th:only-of-type {\n",
1095
+ " vertical-align: middle;\n",
1096
+ " }\n",
1097
+ "\n",
1098
+ " .dataframe tbody tr th {\n",
1099
+ " vertical-align: top;\n",
1100
+ " }\n",
1101
+ "\n",
1102
+ " .dataframe thead th {\n",
1103
+ " text-align: right;\n",
1104
+ " }\n",
1105
+ "</style>\n",
1106
+ "<table border=\"1\" class=\"dataframe\">\n",
1107
+ " <thead>\n",
1108
+ " <tr style=\"text-align: right;\">\n",
1109
+ " <th></th>\n",
1110
+ " <th>a_id</th>\n",
1111
+ " <th>a_title</th>\n",
1112
+ " <th>a_body</th>\n",
1113
+ " <th>a_accepted_answer_id</th>\n",
1114
+ " <th>a_answer_count</th>\n",
1115
+ " <th>a_comment_count</th>\n",
1116
+ " <th>a_community_owned_date</th>\n",
1117
+ " <th>a_creation_date</th>\n",
1118
+ " <th>a_favorite_count</th>\n",
1119
+ " <th>a_last_activity_date</th>\n",
1120
+ " <th>...</th>\n",
1121
+ " <th>q_last_edit_date</th>\n",
1122
+ " <th>q_last_editor_display_name</th>\n",
1123
+ " <th>q_last_editor_user_id</th>\n",
1124
+ " <th>q_owner_display_name</th>\n",
1125
+ " <th>q_owner_user_id</th>\n",
1126
+ " <th>q_parent_id</th>\n",
1127
+ " <th>q_post_type_id</th>\n",
1128
+ " <th>q_score</th>\n",
1129
+ " <th>q_tags</th>\n",
1130
+ " <th>q_view_count</th>\n",
1131
+ " </tr>\n",
1132
+ " </thead>\n",
1133
+ " <tbody>\n",
1134
+ " <tr>\n",
1135
+ " <th>0</th>\n",
1136
+ " <td>58722371</td>\n",
1137
+ " <td>None</td>\n",
1138
+ " <td>&lt;p&gt;The &lt;strong&gt;Attention Mechanism&lt;/strong&gt; is...</td>\n",
1139
+ " <td>None</td>\n",
1140
+ " <td>None</td>\n",
1141
+ " <td>0</td>\n",
1142
+ " <td>NaT</td>\n",
1143
+ " <td>2019-11-06 02:45:52.803000+00:00</td>\n",
1144
+ " <td>None</td>\n",
1145
+ " <td>2019-11-06 02:45:52.803000+00:00</td>\n",
1146
+ " <td>...</td>\n",
1147
+ " <td>2019-11-06 02:46:34.280000+00:00</td>\n",
1148
+ " <td>None</td>\n",
1149
+ " <td>10133797.0</td>\n",
1150
+ " <td>None</td>\n",
1151
+ " <td>10704050.0</td>\n",
1152
+ " <td>None</td>\n",
1153
+ " <td>1</td>\n",
1154
+ " <td>2</td>\n",
1155
+ " <td>python|keras|deep-learning|data-visualization|...</td>\n",
1156
+ " <td>1031</td>\n",
1157
+ " </tr>\n",
1158
+ " <tr>\n",
1159
+ " <th>1</th>\n",
1160
+ " <td>59144361</td>\n",
1161
+ " <td>None</td>\n",
1162
+ " <td>&lt;p&gt;I just finished reading the paper for this ...</td>\n",
1163
+ " <td>None</td>\n",
1164
+ " <td>None</td>\n",
1165
+ " <td>3</td>\n",
1166
+ " <td>NaT</td>\n",
1167
+ " <td>2019-12-02 17:59:35.543000+00:00</td>\n",
1168
+ " <td>None</td>\n",
1169
+ " <td>2019-12-02 23:29:51.047000+00:00</td>\n",
1170
+ " <td>...</td>\n",
1171
+ " <td>NaT</td>\n",
1172
+ " <td>None</td>\n",
1173
+ " <td>NaN</td>\n",
1174
+ " <td>None</td>\n",
1175
+ " <td>10855529.0</td>\n",
1176
+ " <td>None</td>\n",
1177
+ " <td>1</td>\n",
1178
+ " <td>4</td>\n",
1179
+ " <td>python|pytorch</td>\n",
1180
+ " <td>2844</td>\n",
1181
+ " </tr>\n",
1182
+ " <tr>\n",
1183
+ " <th>2</th>\n",
1184
+ " <td>50189281</td>\n",
1185
+ " <td>None</td>\n",
1186
+ " <td>&lt;p&gt;It looks like your OAI server does not acce...</td>\n",
1187
+ " <td>None</td>\n",
1188
+ " <td>None</td>\n",
1189
+ " <td>5</td>\n",
1190
+ " <td>NaT</td>\n",
1191
+ " <td>2018-05-05 12:11:35.753000+00:00</td>\n",
1192
+ " <td>None</td>\n",
1193
+ " <td>2018-05-05 12:11:35.753000+00:00</td>\n",
1194
+ " <td>...</td>\n",
1195
+ " <td>NaT</td>\n",
1196
+ " <td>None</td>\n",
1197
+ " <td>NaN</td>\n",
1198
+ " <td>None</td>\n",
1199
+ " <td>9120635.0</td>\n",
1200
+ " <td>None</td>\n",
1201
+ " <td>1</td>\n",
1202
+ " <td>0</td>\n",
1203
+ " <td>php|xml|oai|oai-pmh</td>\n",
1204
+ " <td>117</td>\n",
1205
+ " </tr>\n",
1206
+ " <tr>\n",
1207
+ " <th>3</th>\n",
1208
+ " <td>62257119</td>\n",
1209
+ " <td>None</td>\n",
1210
+ " <td>&lt;p&gt;I don't think there is the name used by eve...</td>\n",
1211
+ " <td>None</td>\n",
1212
+ " <td>None</td>\n",
1213
+ " <td>0</td>\n",
1214
+ " <td>NaT</td>\n",
1215
+ " <td>2020-06-08 07:33:06.670000+00:00</td>\n",
1216
+ " <td>None</td>\n",
1217
+ " <td>2020-06-08 07:33:06.670000+00:00</td>\n",
1218
+ " <td>...</td>\n",
1219
+ " <td>NaT</td>\n",
1220
+ " <td>None</td>\n",
1221
+ " <td>NaN</td>\n",
1222
+ " <td>None</td>\n",
1223
+ " <td>6495857.0</td>\n",
1224
+ " <td>None</td>\n",
1225
+ " <td>1</td>\n",
1226
+ " <td>-1</td>\n",
1227
+ " <td>nlp|nltk|stanford-nlp|spacy</td>\n",
1228
+ " <td>401</td>\n",
1229
+ " </tr>\n",
1230
+ " <tr>\n",
1231
+ " <th>4</th>\n",
1232
+ " <td>54066401</td>\n",
1233
+ " <td>None</td>\n",
1234
+ " <td>&lt;p&gt;&lt;a href=\"http://jshun.github.io/ligra/\" rel...</td>\n",
1235
+ " <td>None</td>\n",
1236
+ " <td>None</td>\n",
1237
+ " <td>0</td>\n",
1238
+ " <td>NaT</td>\n",
1239
+ " <td>2019-01-06 22:10:02.730000+00:00</td>\n",
1240
+ " <td>None</td>\n",
1241
+ " <td>2019-01-14 15:17:25.297000+00:00</td>\n",
1242
+ " <td>...</td>\n",
1243
+ " <td>NaT</td>\n",
1244
+ " <td>None</td>\n",
1245
+ " <td>NaN</td>\n",
1246
+ " <td>None</td>\n",
1247
+ " <td>10327739.0</td>\n",
1248
+ " <td>None</td>\n",
1249
+ " <td>1</td>\n",
1250
+ " <td>3</td>\n",
1251
+ " <td>multithreading|algorithm|graph|parallel-proces...</td>\n",
1252
+ " <td>1020</td>\n",
1253
+ " </tr>\n",
1254
+ " <tr>\n",
1255
+ " <th>...</th>\n",
1256
+ " <td>...</td>\n",
1257
+ " <td>...</td>\n",
1258
+ " <td>...</td>\n",
1259
+ " <td>...</td>\n",
1260
+ " <td>...</td>\n",
1261
+ " <td>...</td>\n",
1262
+ " <td>...</td>\n",
1263
+ " <td>...</td>\n",
1264
+ " <td>...</td>\n",
1265
+ " <td>...</td>\n",
1266
+ " <td>...</td>\n",
1267
+ " <td>...</td>\n",
1268
+ " <td>...</td>\n",
1269
+ " <td>...</td>\n",
1270
+ " <td>...</td>\n",
1271
+ " <td>...</td>\n",
1272
+ " <td>...</td>\n",
1273
+ " <td>...</td>\n",
1274
+ " <td>...</td>\n",
1275
+ " <td>...</td>\n",
1276
+ " <td>...</td>\n",
1277
+ " </tr>\n",
1278
+ " <tr>\n",
1279
+ " <th>3279</th>\n",
1280
+ " <td>47009439</td>\n",
1281
+ " <td>None</td>\n",
1282
+ " <td>&lt;p&gt;I would strongly suggest against using freq...</td>\n",
1283
+ " <td>None</td>\n",
1284
+ " <td>None</td>\n",
1285
+ " <td>0</td>\n",
1286
+ " <td>NaT</td>\n",
1287
+ " <td>2017-10-30 06:46:48.830000+00:00</td>\n",
1288
+ " <td>None</td>\n",
1289
+ " <td>2017-10-30 06:46:48.830000+00:00</td>\n",
1290
+ " <td>...</td>\n",
1291
+ " <td>2017-10-30 09:54:36.833000+00:00</td>\n",
1292
+ " <td>None</td>\n",
1293
+ " <td>1714410.0</td>\n",
1294
+ " <td>None</td>\n",
1295
+ " <td>6454217.0</td>\n",
1296
+ " <td>None</td>\n",
1297
+ " <td>1</td>\n",
1298
+ " <td>-2</td>\n",
1299
+ " <td>python|c++|image-processing|fft|image-segmenta...</td>\n",
1300
+ " <td>320</td>\n",
1301
+ " </tr>\n",
1302
+ " <tr>\n",
1303
+ " <th>3280</th>\n",
1304
+ " <td>66288381</td>\n",
1305
+ " <td>None</td>\n",
1306
+ " <td>&lt;p&gt;I would say behavior such as this is to be ...</td>\n",
1307
+ " <td>None</td>\n",
1308
+ " <td>None</td>\n",
1309
+ " <td>0</td>\n",
1310
+ " <td>NaT</td>\n",
1311
+ " <td>2021-02-20 05:37:33.433000+00:00</td>\n",
1312
+ " <td>None</td>\n",
1313
+ " <td>2021-02-20 05:37:33.433000+00:00</td>\n",
1314
+ " <td>...</td>\n",
1315
+ " <td>2021-03-03 07:22:26.220000+00:00</td>\n",
1316
+ " <td>None</td>\n",
1317
+ " <td>14692.0</td>\n",
1318
+ " <td>None</td>\n",
1319
+ " <td>14253961.0</td>\n",
1320
+ " <td>None</td>\n",
1321
+ " <td>1</td>\n",
1322
+ " <td>3</td>\n",
1323
+ " <td>tensorflow-federated|federated-learning</td>\n",
1324
+ " <td>139</td>\n",
1325
+ " </tr>\n",
1326
+ " <tr>\n",
1327
+ " <th>3281</th>\n",
1328
+ " <td>66288150</td>\n",
1329
+ " <td>None</td>\n",
1330
+ " <td>&lt;p&gt;How is the test accuracy calculated? How ma...</td>\n",
1331
+ " <td>None</td>\n",
1332
+ " <td>None</td>\n",
1333
+ " <td>1</td>\n",
1334
+ " <td>NaT</td>\n",
1335
+ " <td>2021-02-20 04:51:46.420000+00:00</td>\n",
1336
+ " <td>None</td>\n",
1337
+ " <td>2021-02-20 04:51:46.420000+00:00</td>\n",
1338
+ " <td>...</td>\n",
1339
+ " <td>2021-03-03 07:22:26.220000+00:00</td>\n",
1340
+ " <td>None</td>\n",
1341
+ " <td>14692.0</td>\n",
1342
+ " <td>None</td>\n",
1343
+ " <td>14253961.0</td>\n",
1344
+ " <td>None</td>\n",
1345
+ " <td>1</td>\n",
1346
+ " <td>3</td>\n",
1347
+ " <td>tensorflow-federated|federated-learning</td>\n",
1348
+ " <td>139</td>\n",
1349
+ " </tr>\n",
1350
+ " <tr>\n",
1351
+ " <th>3282</th>\n",
1352
+ " <td>50892512</td>\n",
1353
+ " <td>None</td>\n",
1354
+ " <td>&lt;p&gt;Be aware that &lt;a href=\"http://%20%20%20[1]:...</td>\n",
1355
+ " <td>None</td>\n",
1356
+ " <td>None</td>\n",
1357
+ " <td>0</td>\n",
1358
+ " <td>NaT</td>\n",
1359
+ " <td>2018-06-16 23:24:22.767000+00:00</td>\n",
1360
+ " <td>None</td>\n",
1361
+ " <td>2018-06-16 23:24:22.767000+00:00</td>\n",
1362
+ " <td>...</td>\n",
1363
+ " <td>2018-04-24 12:29:02.223000+00:00</td>\n",
1364
+ " <td>None</td>\n",
1365
+ " <td>5974433.0</td>\n",
1366
+ " <td>None</td>\n",
1367
+ " <td>881141.0</td>\n",
1368
+ " <td>None</td>\n",
1369
+ " <td>1</td>\n",
1370
+ " <td>9</td>\n",
1371
+ " <td>machine-learning|neural-network|nlp|deep-learn...</td>\n",
1372
+ " <td>3310</td>\n",
1373
+ " </tr>\n",
1374
+ " <tr>\n",
1375
+ " <th>3283</th>\n",
1376
+ " <td>21355344</td>\n",
1377
+ " <td>None</td>\n",
1378
+ " <td>&lt;p&gt;Nor will you ever understand how to calcula...</td>\n",
1379
+ " <td>None</td>\n",
1380
+ " <td>None</td>\n",
1381
+ " <td>0</td>\n",
1382
+ " <td>NaT</td>\n",
1383
+ " <td>2014-01-25 19:41:47.890000+00:00</td>\n",
1384
+ " <td>None</td>\n",
1385
+ " <td>2014-01-25 19:41:47.890000+00:00</td>\n",
1386
+ " <td>...</td>\n",
1387
+ " <td>2014-01-25 19:32:46.570000+00:00</td>\n",
1388
+ " <td>None</td>\n",
1389
+ " <td>2462245.0</td>\n",
1390
+ " <td>None</td>\n",
1391
+ " <td>2462245.0</td>\n",
1392
+ " <td>None</td>\n",
1393
+ " <td>1</td>\n",
1394
+ " <td>2</td>\n",
1395
+ " <td>c|simulation|computational-geometry|game-physi...</td>\n",
1396
+ " <td>1844</td>\n",
1397
+ " </tr>\n",
1398
+ " </tbody>\n",
1399
+ "</table>\n",
1400
+ "<p>3284 rows × 40 columns</p>\n",
1401
+ "</div>"
1402
+ ],
1403
+ "text/plain": [
1404
+ " a_id a_title a_body \\\n",
1405
+ "0 58722371 None <p>The <strong>Attention Mechanism</strong> is... \n",
1406
+ "1 59144361 None <p>I just finished reading the paper for this ... \n",
1407
+ "2 50189281 None <p>It looks like your OAI server does not acce... \n",
1408
+ "3 62257119 None <p>I don't think there is the name used by eve... \n",
1409
+ "4 54066401 None <p><a href=\"http://jshun.github.io/ligra/\" rel... \n",
1410
+ "... ... ... ... \n",
1411
+ "3279 47009439 None <p>I would strongly suggest against using freq... \n",
1412
+ "3280 66288381 None <p>I would say behavior such as this is to be ... \n",
1413
+ "3281 66288150 None <p>How is the test accuracy calculated? How ma... \n",
1414
+ "3282 50892512 None <p>Be aware that <a href=\"http://%20%20%20[1]:... \n",
1415
+ "3283 21355344 None <p>Nor will you ever understand how to calcula... \n",
1416
+ "\n",
1417
+ " a_accepted_answer_id a_answer_count a_comment_count \\\n",
1418
+ "0 None None 0 \n",
1419
+ "1 None None 3 \n",
1420
+ "2 None None 5 \n",
1421
+ "3 None None 0 \n",
1422
+ "4 None None 0 \n",
1423
+ "... ... ... ... \n",
1424
+ "3279 None None 0 \n",
1425
+ "3280 None None 0 \n",
1426
+ "3281 None None 1 \n",
1427
+ "3282 None None 0 \n",
1428
+ "3283 None None 0 \n",
1429
+ "\n",
1430
+ " a_community_owned_date a_creation_date a_favorite_count \\\n",
1431
+ "0 NaT 2019-11-06 02:45:52.803000+00:00 None \n",
1432
+ "1 NaT 2019-12-02 17:59:35.543000+00:00 None \n",
1433
+ "2 NaT 2018-05-05 12:11:35.753000+00:00 None \n",
1434
+ "3 NaT 2020-06-08 07:33:06.670000+00:00 None \n",
1435
+ "4 NaT 2019-01-06 22:10:02.730000+00:00 None \n",
1436
+ "... ... ... ... \n",
1437
+ "3279 NaT 2017-10-30 06:46:48.830000+00:00 None \n",
1438
+ "3280 NaT 2021-02-20 05:37:33.433000+00:00 None \n",
1439
+ "3281 NaT 2021-02-20 04:51:46.420000+00:00 None \n",
1440
+ "3282 NaT 2018-06-16 23:24:22.767000+00:00 None \n",
1441
+ "3283 NaT 2014-01-25 19:41:47.890000+00:00 None \n",
1442
+ "\n",
1443
+ " a_last_activity_date ... q_last_edit_date \\\n",
1444
+ "0 2019-11-06 02:45:52.803000+00:00 ... 2019-11-06 02:46:34.280000+00:00 \n",
1445
+ "1 2019-12-02 23:29:51.047000+00:00 ... NaT \n",
1446
+ "2 2018-05-05 12:11:35.753000+00:00 ... NaT \n",
1447
+ "3 2020-06-08 07:33:06.670000+00:00 ... NaT \n",
1448
+ "4 2019-01-14 15:17:25.297000+00:00 ... NaT \n",
1449
+ "... ... ... ... \n",
1450
+ "3279 2017-10-30 06:46:48.830000+00:00 ... 2017-10-30 09:54:36.833000+00:00 \n",
1451
+ "3280 2021-02-20 05:37:33.433000+00:00 ... 2021-03-03 07:22:26.220000+00:00 \n",
1452
+ "3281 2021-02-20 04:51:46.420000+00:00 ... 2021-03-03 07:22:26.220000+00:00 \n",
1453
+ "3282 2018-06-16 23:24:22.767000+00:00 ... 2018-04-24 12:29:02.223000+00:00 \n",
1454
+ "3283 2014-01-25 19:41:47.890000+00:00 ... 2014-01-25 19:32:46.570000+00:00 \n",
1455
+ "\n",
1456
+ " q_last_editor_display_name q_last_editor_user_id q_owner_display_name \\\n",
1457
+ "0 None 10133797.0 None \n",
1458
+ "1 None NaN None \n",
1459
+ "2 None NaN None \n",
1460
+ "3 None NaN None \n",
1461
+ "4 None NaN None \n",
1462
+ "... ... ... ... \n",
1463
+ "3279 None 1714410.0 None \n",
1464
+ "3280 None 14692.0 None \n",
1465
+ "3281 None 14692.0 None \n",
1466
+ "3282 None 5974433.0 None \n",
1467
+ "3283 None 2462245.0 None \n",
1468
+ "\n",
1469
+ " q_owner_user_id q_parent_id q_post_type_id q_score \\\n",
1470
+ "0 10704050.0 None 1 2 \n",
1471
+ "1 10855529.0 None 1 4 \n",
1472
+ "2 9120635.0 None 1 0 \n",
1473
+ "3 6495857.0 None 1 -1 \n",
1474
+ "4 10327739.0 None 1 3 \n",
1475
+ "... ... ... ... ... \n",
1476
+ "3279 6454217.0 None 1 -2 \n",
1477
+ "3280 14253961.0 None 1 3 \n",
1478
+ "3281 14253961.0 None 1 3 \n",
1479
+ "3282 881141.0 None 1 9 \n",
1480
+ "3283 2462245.0 None 1 2 \n",
1481
+ "\n",
1482
+ " q_tags q_view_count \n",
1483
+ "0 python|keras|deep-learning|data-visualization|... 1031 \n",
1484
+ "1 python|pytorch 2844 \n",
1485
+ "2 php|xml|oai|oai-pmh 117 \n",
1486
+ "3 nlp|nltk|stanford-nlp|spacy 401 \n",
1487
+ "4 multithreading|algorithm|graph|parallel-proces... 1020 \n",
1488
+ "... ... ... \n",
1489
+ "3279 python|c++|image-processing|fft|image-segmenta... 320 \n",
1490
+ "3280 tensorflow-federated|federated-learning 139 \n",
1491
+ "3281 tensorflow-federated|federated-learning 139 \n",
1492
+ "3282 machine-learning|neural-network|nlp|deep-learn... 3310 \n",
1493
+ "3283 c|simulation|computational-geometry|game-physi... 1844 \n",
1494
+ "\n",
1495
+ "[3284 rows x 40 columns]"
1496
+ ]
1497
+ },
1498
+ "execution_count": 57,
1499
+ "metadata": {},
1500
+ "output_type": "execute_result"
1501
+ }
1502
+ ],
1503
+ "source": [
1504
+ "df_qa"
1505
+ ]
1506
+ },
1507
+ {
1508
+ "cell_type": "code",
1509
+ "execution_count": 58,
1510
+ "metadata": {},
1511
+ "outputs": [],
1512
+ "source": [
1513
+ "# save the results to a csv file\n",
1514
+ "df_qa.to_csv('/Users/ag2435/repos/stackexchange/stackoverflow/train.csv', index=False)"
1515
+ ]
1516
+ },
1517
+ {
1518
+ "cell_type": "code",
1519
+ "execution_count": null,
1520
+ "metadata": {},
1521
+ "outputs": [],
1522
+ "source": []
1523
+ }
1524
+ ],
1525
+ "metadata": {
1526
+ "kernelspec": {
1527
+ "display_name": "arxiv-agent",
1528
+ "language": "python",
1529
+ "name": "python3"
1530
+ },
1531
+ "language_info": {
1532
+ "codemirror_mode": {
1533
+ "name": "ipython",
1534
+ "version": 3
1535
+ },
1536
+ "file_extension": ".py",
1537
+ "mimetype": "text/x-python",
1538
+ "name": "python",
1539
+ "nbconvert_exporter": "python",
1540
+ "pygments_lexer": "ipython3",
1541
+ "version": "3.12.0"
1542
+ }
1543
+ },
1544
+ "nbformat": 4,
1545
+ "nbformat_minor": 2
1546
+ }
stackexchange.ipynb ADDED
The diff for this file is too large to render. See raw diff