Skip to content

Instantly share code, notes, and snippets.

View kokes's full-sized avatar

Ondrej Kokes kokes

View GitHub Profile
@kokes
kokes / koubsky.ipynb
Last active September 25, 2015 19:59
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokes
kokes / strukturalni-fondy.ipynb
Created September 27, 2015 11:27
Strukturální fondy EU, probraný v Pythonu
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Pěkný to neni, ale zdá se že funguje
# edit: případně vlastně můžem embednout iconv do argumentu gsubu
paste0(unlist(lapply(strsplit(Z, "'")[[1]], function(a) {gsub("'","",iconv(a, to='ASCII//TRANSLIT'))})), collapse="'")
# > Z="příliš žluťoučký 'kůň' s 'apostrofama'"
# > paste0(unlist(lapply(strsplit(Z, "'")[[1]], function(a) {gsub("'","",iconv(a, to='ASCII//TRANSLIT'))})), collapse="'")
# [1] "prilis zlutoucky 'kun' s 'apostrofama"
@kokes
kokes / df-multiindex.ipynb
Created March 2, 2016 19:19
Test of pandas issue #4896 and #10344
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokes
kokes / mixplot.R
Created March 6, 2016 16:33
Mixplots of normal mixtures in R
library(mclust)
mixplot <- function(ts,plot=TRUE) {
rng=seq(from=min(ts),to=max(ts),by=(max(ts)-min(ts))/1000)
mcp = Mclust(ts)$par
mat=cbind(mcp$mean,mcp$var$sigmasq,mcp$pro)
dens=apply(mat[,-3],1,function(x) dnorm(rng,mean=x[1],sd=sqrt(x[2])))
f=dens%*%mat[,3]
if (plot) {
hist(ts,breaks=100,border="gray",probability=TRUE,main="")
@kokes
kokes / strukturalni-fondy-ipy.ipynb
Created March 6, 2016 16:34
Dnes už starý hrátky s datama ke strukturálním fondům
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokes
kokes / Issue_2728.ipynb
Created March 10, 2016 13:35
Trying to replicate pandas issue #2728
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokes
kokes / Issue_744.ipynb
Created March 13, 2016 10:07
Recreating issue #744 in pandas.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kokes
kokes / indexuj.js
Last active March 24, 2016 18:27
Z textu stena do indexu pro lunr.js
var lunr = require('lunr')
var jf = require('jsonfile')
var glob = require('glob')
var dia = require('diacritics').remove
var idx = lunr(function() {
this.ref('id')
this.field('autor')
this.field('tema')
this.field('text')