This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On ubuntu, this is needed to compile Cairo: | |
# sudo apt-get install libcairo2-dev | |
# sudo apt-get install libxt-dev | |
# install.packages('Cairo') | |
library(ggplot2) | |
# Regular png | |
png('test1-png.png') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "test" | |
output: | |
md_document: | |
variant: markdown_github | |
--- | |
```{r pressure, echo=FALSE} | |
plot(pressure) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"border": "pixel", | |
"floating": "auto_off", | |
"layout": "stacked", | |
"percent": 1, | |
"type": "con", | |
"nodes": [ | |
{ | |
"border": "pixel", | |
"current_border_width": 3, |
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 7.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"name","link" | |
"Average Load Of Goods Trains (All Tracation) Broad Gauge and Metre Gauge upto 2013-14","https://data.gov.in/resources/average-load-goods-trains-all-tracation-broad-gauge-and-metre-gauge-upto-2013-14/download" | |
"Average Number Of Locomotives In Use Daily (Diesel) Narrow Gauge upto 2013-14","https://data.gov.in/resources/average-number-locomotives-use-daily-diesel-narrow-gauge-upto-2013-14/download" | |
"Average Number Of Locomotives In Use Daily (Electric) Metre Gauge upto 2013-14","https://data.gov.in/resources/average-number-locomotives-use-daily-electric-metre-gauge-upto-2013-14/download" | |
"Engine Usage - Engine Kilometres Per Day Per Engine In Use Goods upto 2013-14","https://data.gov.in/resources/engine-usage-engine-kilometres-day-engine-use-goods-upto-2013-14/download" | |
"Average Number Of Locomotives In Use Daily (Diesel) Broad Gauge upto 2013-14","https://data.gov.in/resources/average-number-locomotives-use-daily-diesel-broad-gauge-upto-2013-14/download" | |
"Average Number Of Locomotives In Use Dai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dualplot <- function(x1, y1, y2, x2 = x1, | |
col = c("#C54E6D", "#009380"), | |
lwd = c(1, 1), colgrid = NULL, | |
mar = c(3, 6, 3, 6) + 0.1, | |
ylab1 = paste(substitute(y1), collapse = ""), | |
ylab2 = paste(substitute(y2), collapse = ""), | |
nxbreaks = 5, | |
yleg1 = paste(gsub("\n$", "", ylab1), "(left axis)"), | |
yleg2 = paste(ylab2, "(right axis)"), | |
ylim1 = NULL, ylim2 = NULL, ylim.ref = NULL, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.enex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(networkD3) | |
library(magrittr) | |
library(dplyr) | |
library(readr) | |
library(tidyr) | |
tmp <- read_csv('sankey-data.csv', skip = 2) | |
tmp <- tmp[-(21:22),] | |
names(tmp) <- c("X1", "Maharashtra", "Gujarat", "Karnataka", "Andhra Pradesh", | |
"Uttarakhand", "Rajasthan", "Madhya Pradesh", "West Bengal", "Tamil Nadu", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Search and Download datasets from data.gov.in" | |
author: "Sainath Adapa" | |
date: "25 March 2017" | |
output: | |
ioslides_presentation: | |
highlight: pygments | |
widescreen: yes | |
smaller: true | |
df_print: paged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def glimpse(df, maxvals=10, maxlen=110): | |
print('Shape: ', df.shape) | |
def pad(y): | |
max_len = max([len(x) for x in y]) | |
return [x.ljust(max_len) for x in y] | |
# Column Name | |
toprnt = pad(df.columns.tolist()) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def anti_join(x, y, on): | |
"""Return rows in x which are not present in y""" | |
ans = pd.merge(left=x, right=y, how='left', indicator=True, on=on) | |
ans = ans.loc[ans._merge == 'left_only', :].drop(columns='_merge') | |
return ans | |
def anti_join_all_cols(x, y): |
OlderNewer