Editing Community Data Science Course (Spring 2023)/Week 6 coding challenges

From CommunityData
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
This week there are three sets of questions. To answer to the first two sets of questions, you'll want to work from the notebooks I talked through in class during the [[../Week 6 lecture]]. The good news is that answering these will mostly involve modifying or adding small amounts of code (maybe even code we've done in previous assignments!) to those notebooks.
This week there are three sets of questions. To answer to the first two, you'll want to work closely from the notebooks I talked through in class during the [[../Week 6 lecture]]. The good news is that answering these will mostly involve modifying or adding small amounts of code (maybe even code we've done in previous assignments!) to those notebooks.


Feel free to use spreadsheets for any part of this that you can but be sure to share links to the spreadsheets in the same way you've been doing.
Feel free to use spreadsheets for any part of this that you can but be sure to share links to the spreadsheets in the same way you've been doing.
Line 14: Line 14:
== #1 MediaWiki API ==  
== #1 MediaWiki API ==  


Identify a movie, television, video game, or other media property that has both (a) 5 or more related articles on Wikipedia '''and''' (b) 5 or more other articles on the same topic on a [https://fandom.com Fandom.com] website. Any large entertainment franchise will definitely work but feel free to get creative! For example, you might choose 5 Wikipedia articles about the anime Naruto and 5 articles (pages) from the naruto.fandom.com site. You may notice that fandom.com has a top layer with staff-produced video content, but once you dig down into a particular fandom's wiki, you'll start to see a more familiar wiki style page. For example, compare [https://spongebob.fandom.com/wiki/Help_Wanted the fandom.com page about the SpongeBob pilot episode 'Help Wanted'] and [https://en.wikipedia.org/wiki/Help_Wanted_(SpongeBob_SquarePants) the Wikipedia page about the same pilot episode].
Identify a movie, television, video game, or other media property that has both (a) 5 or more related articles on Wikipedia *and* (b) 5 or more other articles on the same topic on a [https://fandom.com Fandom.com] website. Any large entertainment franchise will definitely work but feel free to get creative! For example, you might choose 5 Wikipedia articles about the anime Naruto and 5 articles (pages) from the naruto.fandom.com site.


# First modify the code from first sets of notebooks I used in the [[../Week 6 lecture]] to download data (and metadata) about revisions to the 5 articles you chose from Wikipedia. Be ready to share:
# First modify the code from first sets of notebooks I used in the [[../Week 6 lecture]] to download data (and metadata) about revisions to the 5 articles you chose from Wikipedia. Be ready to share:
## (i) what proportion of those edits were made by users without accounts ("anon"),
## (i) what proportion of those edits were made by users without accounts
## (ii) what proportion of those edits were marked as "minor", and  
## (ii) what proportion of those edits were marked as "minor", and  
## (iii) make and share a visualization of the total number of edits across those 5 articles over time (I didn't do this in class but I made the TSV file would allow this).
## (iii) make and share a visualization of the total number of edits across those 5 articles over time (I didn't do this in class but I made the TSV file would allow this).
Line 26: Line 26:


# Get set up on [https://fusion.yelp.com/ the Yelp Fusion API]. I've put some details on how to do that on the page on a [[Yelp Authentication setup]] page which will likely be very useful!
# Get set up on [https://fusion.yelp.com/ the Yelp Fusion API]. I've put some details on how to do that on the page on a [[Yelp Authentication setup]] page which will likely be very useful!
# Install the <code>yelpapi</code> module which is online: there's both [https://pypi.org/project/yelpapi/ a documentation page] on the [https://pypi.org/ the Python Package Index (PyPI) website] and [https://github.com/lanl/yelpapi a Github page with some documentation]. As I said in class, you can either do this by (a) opening a terminal on your system and running <code>pip install yelpapi</code> or you can try running <code>pip install yelpapi</code> in your Jupyter notebook. Reach on out teams or in open lab sessions if you run into trouble.
# Install the <code>yelpapi</code> module which is online: there's both [https://pypi.org/project/yelpapi/ a documentation page] on the [https://pypi.org/ the Python Package Index (PyPI) website] and [https://github.com/lanl/yelpapi a Github page with some documentation]. As I said in class, you can either do this by (a) opening a terminal on your system and running <code>pip install yelpapi</code> or you can try running <code>%run pip install yelpapi</code> in your Jupyter notebook. Reach on out teams or in open lab sessions if you run into trouble.
# Create a new <code>.py</code> file (e.g., I called mine <code>yelp_authentication.py</code>) in the same directory as your Yelp notebooks are using and add your API key to it. Then use the <code>import</code> command to use your API key in a notebook without having the key itself visible in the notebook!
# Create a new <code>.py</code> file (e.g., I called mine <code>yelp_authentication.py</code>) in the same directory as your Yelp notebooks are using and add your API key to it. Then use the <code>import</code> command to use your API key in a notebook without having the key itself visible in the notebook!
# Once you've done this, use your yelp data collection notebook to grab a list of 50 businesses of any kind (your choice!), in any city (again, your choice!) using Yelp and the <code>yelpapi</code> module. This should be easy if you modify the notebook from the [[../Week 6 lecture]].
# Once you've done this, use your yelp data collection notebook to grab a list of 50 businesses of any kind (your choice!), in any city (again, your choice!) using Yelp and the <code>yelpapi</code> module. This should be easy if you modify the notebook from the [[../Week 6 lecture]].
Please note that all contributions to CommunityData are considered to be released under the Attribution-Share Alike 3.0 Unported (see CommunityData:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)