Skip to content

Instantly share code, notes, and snippets.

View amitkaps's full-sized avatar

Amit Kapoor amitkaps

View GitHub Profile
import urllib2
from bs4 import BeautifulSoup
import re
url = "http://geniekids.com/pa"
#url = "http://geniekids.com/pa/Respect-Fundamentals-of-Disciplining"
import scraperwiki
import scraperwiki
import urllib2
from bs4 import BeautifulSoup
import re
"""
#StarBazaar
chain1 = "StarBazaar"
url_base ="https://www.starbazaarindia.com/"
city = ["sl_ahmedabad.html", "sl_aurangabad.html", "sl_bengaluru.html", "sl_chennai.html",
import scraperwiki
import urllib2
from bs4 import BeautifulSoup
import re
url ="https://projecteuler.net/problem="
def get_page(url,num):
content = None
try:
@amitkaps
amitkaps / installed.csv
Last active August 29, 2015 13:57
Shipment and Installed Base data for PCs, Smartphones and Tablets (in million units). Actuals for 2010 to 2012, Estimates for 2013 to 2017
Type Year Total Windows 8 Window 7- OSX + iOS Linux Android RIM BB Symbian Others
PC 2010 1231 0 1145 74 12
PC 2011 1351 0 1262 75 14
PC 2012 1432 0 1339 77 16
PC 2013 1471 300 1071 80 20
PC 2014 1505 540 857 83 25
PC 2015 1534 730 686 86 32
PC 2016 1560 879 549 90 42
PC 2017 1583 995 439 94 55
Tablet 2010 16 0 14 2 0 0
@amitkaps
amitkaps / minard-cities.txt
Created May 26, 2014 10:05
Minard's - Napolean's Campaign to Russia
long lat city
24.0 55.0 Kowno
25.3 54.7 Wilna
26.4 54.4 Smorgoni
26.8 54.3 Moiodexno
27.7 55.2 Gloubokoe
27.6 53.9 Minsk
28.5 54.3 Studienska
28.7 55.5 Polotzk
29.2 54.4 Bobr
@amitkaps
amitkaps / Multi Variable Visualization
Created May 5, 2015 02:36
Moving up the ladder of multi variable visualisation (in R)
library(ggplot2)
?mpg
head(mpg)
str(mpg)
# Identify a scatter point
attach(mtcars)
plot(mpg, wt)
identify(x = mpg, y = wt, n = 3, label = row.names(mtcars))
detach(mtcars)
## Scraper One
library(rvest)
url = "http://nuforc.org/webreports/ndxe201507.html"
pg <- html(url)
nodes <- html_nodes(pg, "table")
table <- html_table(nodes)
str(table)
View(table)
# Alternate pipe function
# Load the library
library(ggplot2)
library(ggmap)
# Create a dummy data frame of points
set.seed(500)
df <- round(data.frame(
lon = jitter(rep( 77.59, 50), amount = .3),
lat = jitter(rep( 12.97, 50), amount = .3)
), digits = 2)
@amitkaps
amitkaps / rbokeh.R
Created September 10, 2015 05:15
Explore rbokeh library in R
library(dplyr)
library(ggplot2)
library(rbokeh)
########################
# Layering
########################
# Histogram & Density Plot - Price
ggplot(diamonds) + aes(price, y = ..density..) +
@amitkaps
amitkaps / Bar_html.html
Last active October 5, 2015 20:41
Bar Chart - HTML
<!DOCTYPE html>
<style>
#chart div {
background-color: brown;
height: 25px;
margin: 5px;
}
</style>