Categories
data science

Reading a file using Flask – Python

This took me ages to figure out, and it was tough getting a simple straightforward answer… BTW – I’m assuming that you know all the Flask basics, so I won’t be covering that. If you don’t, I suggest you go through their amazing tutorial. This is what I want: I want my web app to […]

Categories
data science

Character encoding in with JSON and PYTHON

I was data scraping the other day and saving the output to a JSON file, but the text in one of the entries was coming out wrong. Instead of “Antal Dovcs√°k”, it was coming out as “Antal Dovcs\u00e1k” instead. For context, my code looked something like this: And the output was this… After some googling […]

Categories
data science

Using the .isin() function in Pandas – Python

The .isin() function is a powerful tool that can help you search search for a number of values in a data frame. This is how it’s done. We start by creating a simple data frame The data frame should look something like this Now, we will use the .isin() function to select all the rows […]

Categories
data science

Create a range of dates using Pandas – Python

Here is how to create a range of dates using the Pandas module. The range will start from April 2 2014 and will end October 1 2014. Well…here it is That’s pretty much it!

Categories
data science

Reddit User Info – Python

This one is just for me. No explanation. As is. This script will let you download all the posts submitted by any Reddit user. Just put the user name in line 9.

Categories
data science

Exploring jason files – Python

Working with json files can be freaking horrible, specially if you don’t know what data is in the file. Let me give you and example of how unreadable it can be. If you use Apple’s iTunes search API, and you search for user id 112018 you get this in return Which is crappy because you […]

Categories
data science

Bibtex to YAML – Python

I’m writing my thesis right now, so I haven’t had much time to post. I am now going through my literature review and I was looking for ways of storing and analysing all my citations so I can do a bit of bibliometrics. Long story short, after trying json and xml, I stumbled across yaml. […]

Categories
data science

Smooth Line Plots – Python

Just a very quick and dirty reminder of how to do this, starting with a data frame. Most of the info in this port can be found here. We can load the data frame (its a csv file) and check the data That should return The ones we want to plot are the 3 *_pec […]

Categories
data science

Timing Execution – Python

This is a simple function that can help you time the code. All it does is use time() from the time module to saves the current time when the code begins, then saves the current time when it ends, and then calculates the difference. Then it uses the gmtime and strtime to format the calculated […]

Categories
data science

Building a Local Library – Python

This may not be the ideal way of doing, but it’s how I’m doing it for now. To build a local library with all the modules you write you should move the modules to the python, a process which is explained here. The main problem, however, is that if you want to edit them, then […]