Screen Link: Learn data science with Python and R projects
My Code:
%%capture
%load_ext sql
%sql sqlite:///Stack Exchange Data Explorer
%%sql
SELECT Id, CreationDate,
Score, ViewCount,
Tags, AnswerCount,
FavoriteCount
FROM posts
WHERE PostTypeId = 1 AND CreationDate = 2019;
What I expected to happen:
Posts table
What actually happened:
(sqlite3.OperationalError) no such table: posts
[SQL: SELECT Id, CreationDate,
Score, ViewCount,
Tags, AnswerCount,
FavoriteCount
FROM posts
WHERE PostTypeId = 1 AND CreationDate = 2019;]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Do I need to add the code to connect SQL? I’ve added it but it still doesn’t work…
Although I haven’t done this mission yet, I believe we are meant to go to the Stack Exchange Data Explorer website in order to explore the dataset as is shown in the animated GIF.
I tried out your code above using the provided link and I did not get back any results. I had to remove part of your WHERE
clause because CreationDate = 2019
was always False
. Once I removed it, I got some results for the query.
EDIT_1:
In fact, the instructions on the following screen tell us explicitly that we should be using the SEDE:
- Run a query against the SEDE DSSE database that extracts the columns listed above for all the questions in 2019.
EDIT_2:
Now that I see this is actually an exercise on screen 4, I had to figure out how to get that part of your WHERE
clause to work. It took this syntax to produce the desired results:
WHERE CreationDate LIKE '%2019%'
1 Like
I try the below code
SELECT Id, CreationDate,
Score, ViewCount, Tags,
AnswerCount, FavoriteCount
FROM posts
WHERE CreationDate LIKE '%2019%';
while it shows the error below:
File "<ipython-input-11-8948c32445ff>", line 1
SELECT Id, CreationDate,
^
SyntaxError: invalid syntax
I can’t see anything wrong in the select columns…
Also, Mike, I’ve tried to upload guided projects to Github but fail… Anyone I can contact with?
Kind regards,
Jessie