Category: Python

Twitter API Streaming in Python

Maybe the easiest way to connect to Twitter API and to stream tweets, is using Python and Tweepy. You can install Tweepy using pip: Tweepy is an open source library and you can check the source here. Maybe, take a peak at StreamListener class and see what additional options are available. ‘Nuff said. Here’s the ...

Google’s PageRank Algorithm in Python

Have you ever asked yourself how google ranks the pages when you search something on google.com? If yes, have a look at PageRank algorithm definition. I’ll not go into much details here, but to give you an idea, the World Wide Web can be seen as a large graph, consisting of pages as nodes and ...

Anonymous Web Scraping with Python Selenium PhantomJS Xpath and TOR

Using pure selenium methods to extract data from metasearch websites is quite tricky and uses a lot of CPU resources. I have spent significant amount of time with selenium built-in methods with python and have a feeling that the development is quite tedious, time consuming and prone to bugs. Selenium’s WebElement objects are not flexible, ...

Searching neighbors in Graph Data Structure by matrix multiplication

Which vertices in graph can be reached in 1, 2 or N hops? This can basically be implemented in two ways. First, if the graph is implemented as adjacency matrix, by checking connections (ones in double array or a row) and iterating further. Second, if the graph structure is implemented as ArrayList, by checking lists of ...

Distribute Missing Values randomly across Columns in Python Pandas

Continuing to the previous post this script distributes missing values across all features in Pandas DataFrame. Just set min and max missing value distribution and you’re ready to execute … Enjoy…

Distribute Missing Values in Pandas DataFrame Column with Python

If you want to test how Maschine Learning algorithms perform with missing values you may need a script to distribute a fixed percentage of missing values in a feature. This script randomly distributes missing values in a single data set’s column. Enjoy…

Pandas DataFrame Subsampling in Python

Written long time ago to feed some ML algorithms with data subsets because the original data set was to huge and the algorithm execution performance was too long. Have fun with the script…

Advertisements
Advertisements