Skip to content

Instantly share code, notes, and snippets.

View radovankavicky's full-sized avatar
🐍
Pythonista

Radovan Kavicky radovankavicky

🐍
Pythonista
View GitHub Profile
@radovankavicky
radovankavicky / johnsnow_dataset_deaths_all.csv
Last active December 21, 2017 19:05
Cholera Deaths information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of a Death. The value given in the number of deaths at that location This has been imported from the shapefiles available at http://blog.rtwilson.com/john-snows-famous-cholera-analysis-data-in-moder…
Death X coordinate Y coordinate
1 51.513418 -0.13793
1 51.513418 -0.13793
1 51.513418 -0.13793
1 51.513361 -0.137883
1 51.513361 -0.137883
1 51.513317 -0.137853
1 51.513262 -0.137812
1 51.513204 -0.137767
1 51.513204 -0.137767
@radovankavicky
radovankavicky / johnsnow_dataset_pumps.csv
Last active December 21, 2017 19:06
Pumps information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of a Pump. This has been imported from the shapefiles available at http://blog.rtwilson.com/john-snows-famous-cholera-analysis-data-in-modern-gis-formats/
Pump Name X coordinate Y coordinate
-999 51.513341 -0.136668
-999 51.513876 -0.139586
-999 51.514906 -0.139671
-999 51.512354 -0.13163
-999 51.512139 -0.133594
-999 51.511542 -0.135919
-999 51.510019 -0.133962
-999 51.511295 -0.138199
@radovankavicky
radovankavicky / johnsnow_dataset_deaths.csv
Last active December 21, 2017 19:06
Cholera Deaths information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of Deaths. The value given in the Count field of the number of deaths at that location. This has been imported from the shapefiles available at http://blog.rtwilson.com/john-snows-famous-cholera-ana…
Number of deaths X coordinate Y coordinate
3 51.513418 -0.13793
2 51.513361 -0.137883
1 51.513317 -0.137853
1 51.513262 -0.137812
4 51.513204 -0.137767
2 51.513184 -0.137537
2 51.513359 -0.1382
2 51.513328 -0.138045
3 51.513323 -0.138276
@radovankavicky
radovankavicky / johnsnow_dataset_pumps_deaths_comma_xyswitched.csv
Created December 20, 2017 12:48
Cholera Deaths and Pumps information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of either a Pump or a Death. The value given in the Count field is either: -999 for a pump > 0: the number of deaths at that location This has been imported from the shapefiles available at
Number of deaths X coordinate Y coordinate
3 51.513418 -0.13793
2 51.513361 -0.137883
1 51.513317 -0.137853
1 51.513262 -0.137812
4 51.513204 -0.137767
2 51.513184 -0.137537
2 51.513359 -0.1382
2 51.513328 -0.138045
3 51.513323 -0.138276
@radovankavicky
radovankavicky / johnsnow_dataset_pumps_deaths_comma_xydivided.csv
Created December 20, 2017 12:46
Cholera Deaths and Pumps information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of either a Pump or a Death. The value given in the Count field is either: -999 for a pump > 0: the number of deaths at that location This has been imported from the shapefiles available at
Number of deaths X coordinate Y coordinate
3 -0.13793 51.513418
2 -0.137883 51.513361
1 -0.137853 51.513317
1 -0.137812 51.513262
4 -0.137767 51.513204
2 -0.137537 51.513184
2 -0.1382 51.513359
2 -0.138045 51.513328
3 -0.138276 51.513323
@radovankavicky
radovankavicky / johnsnow_dataset_pumps_deaths_semi_xycombined.csv
Created December 20, 2017 12:42
Cholera Deaths and Pumps information from John Snow's 1854 map of the cholera outbreak in London. Each row represents a location (given in the geometry field) of either a Pump or a Death. The value given in the Count field is either: -999 for a pump > 0: the number of deaths at that location This has been imported from the shapefiles available at
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
Number of deaths;XY coordinates
3;-0.13793,51.513418
2;-0.137883,51.513361
1;-0.137853,51.513317
1;-0.137812,51.513262
4;-0.137767,51.513204
2;-0.137537,51.513184
2;-0.1382,51.513359
2;-0.138045,51.513328
3;-0.138276,51.513323
@radovankavicky
radovankavicky / python-RData.py
Created December 18, 2017 13:51 — forked from LeiG/python-RData.py
Python and .RData files
import rpy2.robjects as robjects
import pandas.rpy.common as com
import pandas as pd
## load .RData and converts to pd.DataFrame
robj = robjects.r.load('test.RData')
# iterate over datasets the file
for sets in robj:
myRData = com.load_data(sets)
# convert to DataFrame
@radovankavicky
radovankavicky / ggplotrbokeh.R
Created December 5, 2017 23:04 — forked from hrbrmstr/ggplotrbokeh.R
ggplot <-> rbokeh
library(ggplot2)
library(rbokeh)
library(htmlwidgets)
structure(list(wk = structure(c(16069, 16237, 16244, 16251, 16279,
16286, 16300, 16307, 16314, 16321, 16328, 16335, 16342, 16349,
16356, 16363, 16377, 16384, 16391, 16398, 16412, 16419, 16426,
16440, 16447, 16454, 16468, 16475, 16496, 16503, 16510, 16517,
16524, 16538, 16552, 16559, 16566, 16573), class = "Date"), n = c(1L,
1L, 1L, 1L, 3L, 1L, 3L, 2L, 4L, 2L, 3L, 2L, 5L, 5L, 1L, 1L, 3L,
# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@radovankavicky
radovankavicky / gg_tweet.R
Created October 23, 2017 18:29 — forked from hrbrmstr/gg_tweet.R
use the magick device to make ggplots conform to twitter card or in-stream image optimal sizes, with or without "retina" resolution
library(httr)
library(magick)
library(hrbrthemes)
library(ggplot2)
theme_tweet_rc <- function(grid = "XY", style = c("stream", "card"), retina=FALSE) {
style <- match.arg(tolower(style), c("stream", "card"))
switch(