Skip to content

Instantly share code, notes, and snippets.

View ygivenx's full-sized avatar
🎯
Focusing

Rohan Singh ygivenx

🎯
Focusing
View GitHub Profile
@ygivenx
ygivenx / tutorial_scraper.py
Last active April 24, 2018 03:51
Scrape List of htmls
from bs4 import BeautifulSoup
import urllib
import os.path
import random
from time import sleep
address = "http://www.datasciencecourse.org/tutorials/"
request = urllib.request.Request(address)
urlfile = urllib.request.urlopen(request)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ygivenx
ygivenx / billionage.md
Last active October 4, 2018 22:47
Billionaire's Age

Age seems to be an interesting variable - lets find out who are the youngest and oldest billionaires?

print("Youngest Billionaire")
display(Image(url=(data.loc[data["age"] == data.age.min()]["image"].iloc[0]),height=100,width=100))
display(data.loc[data["age"] == data.age.min()])

Youngest Billionaire

(mu, sigma) = stats.norm.fit(data.dropna(subset=["age"]).age)
ax = sns.distplot(data.dropna(subset=["age"]).age, color='green')
ax.set(xlabel='Age of Billionaires')
plt.title("Age Distribution of billionaires")
plt.legend(["normal dist. fit ($\mu=${0:.2g}, $\sigma=${1:.2f})".format(mu, sigma)],)

Now let's explore the next interesting variable - gender.

display(data["gender"].value_counts())
sns.countplot("gender",data=data,palette="Set3")
M    1952
@ygivenx
ygivenx / StolenRubies.py
Created October 29, 2018 02:30
Stolen Rubies Problem
###############################################################################
# Stolen Rubies Problem
###############################################################################
from collections import defaultdict
def expectedValueDetective(cardValue, x, y, z):
"""
This functions returns the number of rubies for
a given cardValue and rubies in each box
Expected Value for 1 : 3.0
Expected Value for 2 : 5.777777777777778
Expected Value for 3 : 8.333333333333334
Expected Value for 4 : 10.666666666666666
Expected Value for 5 : 12.777777777777779
Expected Value for 6 : 14.666666666666666
Expected Value for 7 : 15.555555555555555
Expected Value for 8 : 16.0
Expected Value for 9 : 15.0
The card value to be used by the detective is: 8
#!/bin/bash
let i = 1
for f in "."/*
do
echo $i
echo $f
let "i++"
done
function _update_ps1() {
PS1=$(powerline-shell $?)
}
if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
wget https://dumps.wikimedia.org/other/cirrussearch/20180924/enwikiquote-20180924-cirrussearch-content.json.gz