This file contains hidden or 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
(require '[clojure.test.check.generators :as gen] | |
'[criterium.core :refer [quick-bench]] | |
'[incanter.core :refer [$where $fn]]) | |
;; Use test.check to generate some random-ish input. | |
(def tenk-longs (gen/sample (gen/choose 0 10) 10000)) | |
(def tenk-strings (gen/sample (gen/elements ["foo" "bar" "baz" "qux"]) 10000)) | |
;; Dataset, two columns | |
(def test-dataset (incanter.core/dataset {:tenk-long tenk-longs :tenk-str tenk-strings})) |
This file contains hidden or 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
user=> (require '[clojure.test.check.generators :as gen]) | |
nil | |
user=> (require 'incanter.core) | |
nil | |
user=> (def one-mil-longs (gen/sample (gen/choose 0 10) 1000000)) | |
#'user/one-mil-longs | |
user=> (def one-mil-incanter (incanter.core/dataset {:one-mil one-mil-longs})) | |
#'user/one-mil-incanter | |
;; This completely locks my REPL | |
user=> (def where-two (incanter.core/$where {:one-mil 2} one-mil-incanter)) |
This file contains hidden or 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
scala> if (true) { 2 } | |
res1: AnyVal = 2 | |
scala> if (true) { 2 } else { 3.0 } | |
res2: Double = 2.0 |
This file contains hidden or 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
;; Gaussian sum! | |
user=> (crit/with-progress-reporting (crit/quick-bench (/ (* (+ 1 99999) 99999) 2))) | |
Warming up for JIT optimisations 5000000000 ... | |
compilation occured before 333366 iterations | |
Estimating execution count ... | |
Sampling ... | |
Final GC... | |
Checking GC... | |
WARNING: Final GC required 8.548926352381509 % of runtime | |
Finding outliers ... |
This file contains hidden or 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
scala> abstract class FooClass(val foo:String) | |
defined class FooClass | |
scala> class ExtendsFoo(override val foo:String = "foo!") extends FooClass(foo) | |
defined class ExtendsFoo | |
scala> val foo = new ExtendsFoo() | |
foo: ExtendsFoo = ExtendsFoo@3b40500e | |
scala> foo.foo |
This file contains hidden or 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
;; Cardinality 10-10000, seq of 100000 integers | |
(def card10 (gen/sample (gen/choose 0 10) 100000)) | |
(def card100 (gen/sample (gen/choose 0 100) 100000)) | |
(def card1000 (gen/sample (gen/choose 0 1000) 100000)) | |
(def card10000 (gen/sample (gen/choose 0 10000) 100000)) | |
;; Create levels and an integer array representing those levels | |
user=> (time (dotimes [n 5] (def myarr (ca/make-indexed-array card10)))) | |
"Elapsed time: 1841.995 msecs" | |
nil |
This file contains hidden or 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
Across The Hall | |
Are We Late | |
Around the Corner | |
Did You Book A Room | |
Down The Hall | |
Grab That Room | |
Here | |
I Don't Know | |
I'm Not Sure Which One | |
It Got Moved |
This file contains hidden or 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
(.env)Robs-MacBook-Pro:pdxsci robstory$ pip freeze | |
Cython==0.21.1 | |
Flask==0.10.1 | |
Jinja2==2.7.3 | |
Markdown==2.5.1 | |
MarkupSafe==0.23 | |
PyYAML==3.11 | |
Pygments==2.0 | |
Werkzeug==0.9.6 | |
backports.ssl-match-hostname==3.4.0.2 |
This file contains hidden or 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
Robs-MacBook-Pro:pdxsci robstory$ sh pipinstall.sh | |
New python executable in .env/bin/python2.7 | |
Also creating executable in .env/bin/python | |
Installing setuptools, pip...done. | |
Warning: libevent-2.0.21 already installed | |
Warning: libyaml-0.1.6 already installed | |
Downloading/unpacking cython | |
Downloading Cython-0.21.1-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.7MB): 3.7MB downloaded | |
Installing collected packages: cython | |
Successfully installed cython |
This file contains hidden or 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
In [1]: import pandas as pd | |
In [2]: df = pd.DataFrame({"col1": ["one.two", "three.four", "five.six"]}) | |
In [3]: df['col_idx_0'] = df['col1'].str.split('.').str.get(0) | |
In [4]: df['col_idx_1'] = df['col1'].str.split('.').str.get(1) | |
In [5]: df | |
Out[5]: |