Tweepy library, redux

In the previous post, I shared this with you without the OAuth2 authentication codes present, for obvious reasons. That makes it hard for you to see it in action, obviously. Here’s a different take: I’ve saved the output as an HTML file. It includes more of the content, although (frustratingly) the final Google map isn’t visible.

View the HTML version.

Tweepy library demo from this week

THE Tweepy library demo from class this week is available here:

Tweepy library demo

NOTA BENE that the authentication is intentionally broken, so it won’t work for you as-is: You need to add your own authentication (from jupyter running on your laptop) before things will work.

I’ll create a different version that is easier to see online and post it presently.

Questions? Send me a note.

g

gmaps Tutorials

Update

Oh Python! How I hate you. I need to re-revise the files below because Python is throwing a fit inside Binder inside GitHub. You better get your shit together, Python. I will update this update once I have updated that code.

You can see the two pages we’d reviewed last week via Binder.

Note that the maps that (may be) visible on those pages are “left over” from an earlier run. Because I’ve put these online, it was important that I remove at least some of the API key granted to me by Google. I strongly suggest you do the same if and when you put your own material online.

First, installing gmaps via conda-forge.

Second, an introduction to using gmaps.

updating site

I am now in the process of updating the site and adding material back onto it that, prior to now, I’ve not had time to add.  If something is missing, please let me know.  Otherwise, you may need to search around a bit for some things that used to be right up front.

Tutorials: Lists and Loops

Go here

 

Breaking News: Something odd seems to be happening when I try to serve Git-hosted .ipynb pages via Binder.org. It is happening to others’ pages, as well. So let’s cut out the middleman and just serve them up via Jupyter’s notebook viewer website (hosted, it turns out, by Github).

I’ll collect new links for these presently. For the nonce, though, here’s the latest one:

XML Pandas iTunes Tutorial.

OLD NEWS

Further Update: Hey — the binder server seems to be running a bit slow AND/OR crashing unpredictably today. They say they are working on getting it back up and running ASAP. If you click on a notebook / tutorial and it doesn’t open, try again a bit later… Sorry.

UPDATED: Now with more itunes, XML, Pandas-oriented goodness.

More insight into Loops: Tutorial

LISTS are one of the most important things to understand before we tackle things like Twitter and Natural Language Text Processing. Here are two different tutorials to explain them: Intro to Lists and List Tutorial.

If you have time between now and Thursday AM

An unanticipated deadline has kept me from posting the assignment I wanted to give to you this week — so we’ll have to make it up next week. However, if you have some time before class on Thursday, consider the following (not-required) exercise:

If you have time between now and Thursday AM (15 February), this is my challenge to you, with respect to our class in Digital Research Methods and doing data science: Do something that strikes you as interesting or meaningful: Learn a new technique for capturing data; experiment with different versions of a specific function or command. Download and install a different text editor and force yourself to learn a dozen keyboard commands. Go to Github.com and search for snippets of Python code that seem promising to you.

Set out to answer a question that you’ve had about Python for weeks now. “I don’t understand the idea of a “for/in” loop in Python,” you say. So find a few examples online, sit down in front of Jupyter for half an hour, and experiment. Give yourself permission to indulge in evidence-based learning: Start in a blank notebook with an hypothesis about, say, how variables work in Python. Try to disprove that hypothesis, try to break it. Broken? Now put it back together, better this time.

Play with a strange new library just to see what it does. Force yourself to work in Jupyter with one single function until you come to understand it completely and intuitively.

Now this part is *crucial*: **You must, in some small way, document what you have done.** Make a point of learning publicly. Jupyter is perfect for this. I’ve included an imperfect, quickly-built sample, just have a look (note that I’d need to clean it up before I shared it with anyone). If you have the opportunity to experiment with this idea, try to make your effort 50% personal journal (a real, if simplified, record of your self-education) and 50% performative learning (this is what it looks like when I learn; this is the nature of my thought).

SO: Why do this? Here’s my thought: The engineering sciences (and Computer Science) have long been notorious for thinking in chiefly problem-based terms (that is why the advertising industry has been obsessed with the word “solutions” for 30 years now).

If you ask a software engineer a question, there’s a good chance that she is trained to see that question as a problem, and so she’ll define it thus and then move to solve it. OK: That isn’t necessarily a bad thing. But it can be reductive, and limiting, and overly simplistic — even if it is the most “efficient” approach.

Engineers are not (typically) interested in process, only in outcome. If we’re going to have to live with code and data all our lives, I think we’re well-served to see value in process, too. I like the idea of modeling our imperfect, idiosyncratic processes of learning because it suggests that it isn’t just engineers who should be using Python to think. Other people — opera singers and dog walkers and house painters — should do so, too.

Web Scraping Tutorial

The first of a 4-part tutorial on the joys of web scraping. It starts off a little slow, it is true: But while it may not at first seem likely to amount to much, you’ll change your tune when you see what we do with this scraping procedure in sections 3 and 4.

For the time being though:  Check out the tutorial in a Jupyter Notebook.

Text file tutorial

Code is Hard

I’m sure that some of you feel overwhelmed as you work to master these weird, radically new ideas. It is OK to feel that way — just keep chipping away at these fundamentals: Pretty soon some of it will start to feel familiar.
The Slippery Sir Hiss
Not that it will ever feel like home: This technology is evolving too quickly for that. But it doesn’t have to: I’ll never ask you to write code from memory or invent code on-the-spot: That’s not what we’re trying to accomplish here. You will always have access to the references and resources you’ve come to trust; you’ll always be able to lean on others in order to find your answers. This is a class about research, not about programming. In the long-term, I do think that the code we write has the potential to open up, in each of us, new vectors of reason and novel types of critique. But for now, refuse to let yourself be intimidated by it.

The link below will take you to a tutorial that picks up on what we did not finish on Thursday. It does a reasonable job of explaining how to open and read data files in Jupyter. I’ll post a few more of these this afternoon (Sunday, 11 February).

binder

The link itself is actually very interesting to us: I’m using a Jupyter notebook hosting service called “myBinder.” It’s new to me, and still in Beta, so there are some kinks to work out I’m sure, but it makes it so very easy to share your work with your peers as an interactive, live notebook. I just put my .ipynb file on Github and tell Binder to host.

Bonus “It’s a Small World” detail: Guess what happens in the interim? Right: myBinder fires up Docker, and builds your notebook into a custom Docker container that is then launched on demand. See? It all comes full circle!

Tutorial

Work through the tutorial to learn the basics of loading a data file. Sometimes it will seem overly complicated — but don’t be discouraged: Once we get these first principles out of the way, the rest will come much easier. And we can actually focus on the research and our arguments themselves, rather than on Python.

For the nonce, though: IO_Tutorial_One

Site update

I’m re-integrating tutorials and resource lists with the new Jupyter-friendly plugin.  This should be done by 8AM 6 February.

Until then, I encourage you to have a look (and work through) tutorials like the ones shared below.  You can never practice too much with this material.

Important note:  Video tutorials are always tough, and imperfect.  Don’t be discouraged.  Force them to work your way by using the pause button, by re-winding and fast-forwarding, and by activating the (imperfect) automated transcription service (CC) often available for each video.  When they are filled with lots of content I already know, I tend to set the video speed at 1.25 or 1.5; when I want them to slow down, I’ll set the speed to 0.75 (too much slower and it becomes impossible to listen to).

There are a lot of terrible, awful, dreadful tutorials available online.  That’s why I spend so much time writing my own — mine aren’t great, but they tend towards a coherence that others often lack (in fairness, video tutorials, like most digital media, are a lot more work than you’d think.)  But even so, there are some good ones out there — even some great ones.  So here are some that I’ve found useful (or interesting) — maybe you’ll think they are useful, too.

If you find others that you particularly like, please let me know, and I’ll share them ’round.

Again, more of ours available tomorrow (Tuesday).