ISRO’s Mangal Yaan Mission In A Nutshell

Curious about first Indian mission to Mars, then this is one video you shouldn’t miss.

The video explains ISRO’s complex mission in a very simple way and make people aware why space exploration is far more important than anything else.

Excellent work by The Curious Engineer

Rotate

You don’t learn cool things everyday. And today is not everyday, learnt this neat trick to rotate a matrix with a one liner in #python!!!

Rotate_A_matrix_in_python

b = np.array(zip(*a[::-1]))

Simple and powerful. Waiting for a chance to use it somewhere in actual code…

Want to understand what’s happening visit this page by Peter Norvig, director of research Google!!

Guided by Theory

Theory vs PracticalIn one of the talks Charlie Munger says this…..

I could see that I was not going to cope as well as I wished with life unless I could acquire a better theory-structure on which to hang my observations and experiences. By then, my craving for more theory had a long history. Partly, I had always loved theory as an aid in puzzle solving and as a means of satisfying my monkey-like-curiosity. And, partly, I had found that theory-structure was a superpower in helping one get what one wanted. As I had early discovered in school wherein I had excelled without labor, guided by theory, while many others, without mastery of theory failed despite monstrous effort. Better theory I thought had always worked for me and, if now available could make me acquire capital and independence faster and better assist everything I loved.

I have been a fan of action, but now gravitating towards theory!!

Why Choose Python now revealed?

WhyChoosePythonI am playing with reveal.js for a week now. Reveal is html presentation framework. Its awesome. Love the html presentations!!

Moreover Powerpoint!. Ipython notebook and reveal.js are my new presentation tool.

During this week, this particular post “Why Choose Python?” is getting lot of attention, so decided to try reveal on this post…

so here’s the result.

Click on the title below to watch the presentation. Created entirely with ipython notebook!!

Why Choose Python – the presentation

The awesomeness of reveal.js only available on modern browsers (Chrome, Firefox)… IE users, please upgrade.. :)

Fun Experiments with Markov Chain

independancedayA stochastic process is a mathematical model that evolves over time in a probabilistic manner. Markov chain is a special kind of stochastic process, where the outcome of the experiment depends only on the outcome of the previous experiment. That is the next state of the system depends only on the present state, not on preceding states. Markov chains are named after the Russian mathematician A. A. Markov who stated the theory of stochastic processes.

Now what if we mix markov chain and PM Modi’s independence day speech, find the hilarious results in this ipython notebook.

Markov Chain and Modi’s Speech

After this experiment, I know how some of the comment spam is being generated and is fooling the comment filters on wordpress.

Exploring AirWire with Pandas – A Dashboard from Session Histroy

airwire internet usage analyticsLast week received my internet bill and my wife wondered how much data we are using and if someone was snooping at our wifi?

Assured her, this isn’t the case but her doubt lingered.

Went to the ISP website, downloaded the session data and showed her. Still not convinced, so imported the data into pandas.

And that exploration.. produced the above PDF. A dashboard of information mined from the csv file. My wife loved it.

Here’s the script that will produce this pdf. Will be directly useful to anyone using airwire services and for other’s it’s a good starting point.

Continue reading

Little Experiments with BeautifulSoup

cricketwithball
Look at any conference related to python, web scraping is one of the topic that is always there.

This prompted me to BeautifulSoup. I am toying with it for few months now, but yesterday got a real chance to use it.

Here’s a small function that I used yesterday to scrape out all the test match and one day match results from espn website. Someone needed the data.


import urllib2
from bs4 import BeautifulSoup
import csv
def cricketScrap(url,f):
    page = urllib2.urlopen(url).read()
    soup = BeautifulSoup(page)
    table = soup.find('table', attrs={'class': 'engineTable'})
    x = (len(table.findAll('tr')) )
    if x==1:
        return
    
    for row in table.findAll('tr')[1:x]:
        col = row.findAll('td')
        team1 = col[0].getText()
        team2 = col[1].getText()
        winner = col[2].getText()
        margin = col[3].getText()
        ground = col[4].getText()
        match_date = col[5].getText()
        match = (team1, team2, winner, margin, ground, match_date )
        f.writerow(match)

Here’s how to use it.

'''
For one day match

'''

lis=["Team 1","Team 2","Winner","Margin","Ground","Match Date"]
f = csv.writer(open("oneindiancricketscrape.csv", "w"))
f.writerow(lis)

onedayurl=r"http://stats.espncricinfo.com/indian-premier-league-2014/engine/records/team/match_results.html?class=2;team=6;type=year;id="
for year in range(1974,2015):
    cricketScrap(onedayurl+str(year),f)


And here’s the interesting one, scape all results of the matches played between 1772 to 2014


allmatchurl=r"http://stats.espncricinfo.com/indian-premier-league-2014/engine/records/team/match_results.html?class=0;team=0;type=year;id="

lis=["Team 1","Team 2","Winner","Margin","Ground","Match Date"]
f = csv.writer(open("allCricketMatchResults1900.csv", "w"))
f.writerow(lis)


for year in range(1772,2015):
    cricketScrap(allmatchurl+str(year),f)


And if you are just interested in one day and test matches results played by india till now, then click the following links to download the csv files.

Follow

Get every new post delivered to your Inbox.

Join 976 other followers

%d bloggers like this: