Last active
June 1, 2020 02:46
-
-
Save landswellsong/a6f8a1048e3972949c6bb90435527224 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import sys | |
CAND_MAX = 34 | |
print(','.join([ | |
'date', | |
'id', | |
* [ f+e for f in ['ip', 'eml', 'mob'] for e in [ '_start', '_end' ] ], | |
* [ 's' + str(s) for s in range(1,CAND_MAX + 1) ], | |
'k1', | |
'k2' | |
])) | |
def produce_csv_line(date, ID, IP, EML, MOB, SEL, K1, K2, **kwargs): | |
print (','.join([ | |
date, ID, | |
* IP.split('***'), | |
* EML.split('***@***'), | |
* MOB.split('***'), | |
* [ 'T' if s in (int(x) for x in SEL.split(',')) else 'F' for s in range(1,CAND_MAX + 1) ], | |
K1, K2 | |
])) | |
for line in sys.stdin: | |
produce_csv_line(line[:23], **{ k:v for k, v in (x.split('=') for x in line[24:].split()) }) |
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
nabu <- read.csv("nabu_vote.csv") | |
CAND_MAX = 34 | |
vote <- c(4,6,8,10,17,19,24,26,27,30) | |
D7.vote <- apply(nabu[, vote + 8], MARGIN = 1, all) & apply(!nabu[, setdiff(c(1:CAND_MAX), vote) + 8], MARGIN = 1, all) | |
par(mfrow=c(2,2)) | |
hist(nabu.D7[D7.vote,]$mob_end, nclass=100, main="Д7", xlab="Закінчення номеру", col="red") | |
hist(nabu.D7$mob_end, nclass=100, main="Всі голоси", xlab="Закінчення номеру", col="gray50") | |
hist(nabu.D7[!D7.vote,]$mob_end, nclass=100, main="Не Д7 (включно з Д7 + інші кандидати)", xlab="Закінчення номеру", col="blue") | |
plot(ecdf(nabu.D7[D7.vote,]$mob_end), main="ECDF", col="red") | |
plot(ecdf(nabu.D7[!D7.vote,]$mob_end), main="ECDF", col="blue", add=TRUE) | |
plot(ecdf(nabu.D7$mob_end), main="ECDF", col="gray50", add=TRUE) | |
legend("topleft", legend = c("Всі голоси", "Д7", "Не Д7* (див гістограму)"), lty = 1, col = c("gray50", "red", "blue")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment