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 pytest | |
def setup_function(function): | |
foo = 1 | |
function(foo) | |
def test_thing(thing): | |
two = thing + 1 | |
assert two == 2 |
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
scala> val mymap = new ConcurrentHashMap[String, Int] | |
mymap: java.util.concurrent.ConcurrentHashMap[String,Int] = {} | |
scala> mymap.put("one", 1) | |
res8: Int = 0 | |
scala> mymap.put("zero", 0) | |
res9: Int = 0 | |
scala> mymap.get("one") |
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
from random import gauss | |
from IPython.display import clear_output | |
from IPython.html import widgets | |
from IPython.utils.traitlets import link | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline |
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
from IPython.html import widgets | |
toggle = widgets.ToggleButton() | |
def foo(): | |
if toggle.value is True: | |
print("The Toggle is True!") | |
else: | |
print("The Toggle is False!") | |
toggle.on_trait_change(foo) | |
display(toggle) |
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
scala> val listOfTuples = List(("one", Map("foo" -> 1, "bar" -> 2)), | |
| ("two", Map("baz" -> 3, "qux" -> 4)), | |
| ("three", Map())) | |
listOfTuples: List[(String, scala.collection.immutable.Map[_ <: String, Int])] = List((one,Map(foo -> 1, bar -> 2)), (two,Map(baz -> 3, qux -> 4)), (three,Map())) | |
scala> val thirdTuple = listOfTuples(2) | |
thirdTuple: (String, scala.collection.immutable.Map[_ <: String, Int]) = (three,Map()) | |
scala> val thirdTupleMap = thirdTuple._2 | |
thirdTupleMap: scala.collection.immutable.Map[_ <: String, Int] = Map() |
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
scala> val foo = Map("one" -> "two") | |
foo: scala.collection.immutable.Map[String,String] = Map(one -> two) | |
scala> foo.getOrElse("nokey", None) | |
res67: java.io.Serializable = None | |
scala> foo.getOrElse("nokey", null) | |
res68: String = 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
scala> val fooList: List[String] = List() | |
fooList: List[String] = List() | |
scala> foo :+ "one" | |
res117: List[String] = List(one) | |
scala> foo +: "one" | |
res118: scala.collection.immutable.IndexedSeq[Any] = Vector(List(), o, n, e) |
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
Robs-MacBook-Pro:WASKOMDROOLS robstory$ virtualenv .env | |
New python executable in .env/bin/python2.7 | |
Also creating executable in .env/bin/python | |
Installing setuptools, pip...done. | |
Robs-MacBook-Pro:WASKOMDROOLS robstory$ source .env/bin/activate | |
(.env)Robs-MacBook-Pro:WASKOMDROOLS robstory$ pip install matplotlib | |
Downloading/unpacking matplotlib | |
Downloading matplotlib-1.4.3-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 (47.6MB): 47.6MB downloaded | |
Downloading/unpacking nose>=0.11.1 (from matplotlib) | |
Downloading nose-1.3.4-py2-none-any.whl (154kB): 154kB downloaded |
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
In [60]: df = pd.DataFrame({"foo": [1, 2], "bar": [3, 4]}) | |
In [61]: df.rename({"foo": "foo_1", "bar": "bar_1"}) | |
Out[61]: | |
bar foo | |
0 3 1 | |
1 4 2 | |
In [62]: df.rename(columns={"foo": "foo_1", "bar": "bar_1"}) | |
Out[62]: |
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
scala> import scala.collection.mutable.Queue | |
import scala.collection.mutable.Queue | |
scala> var newQ = Queue(1, 2, 3, 4, 5) | |
newQ: scala.collection.mutable.Queue[Int] = Queue(1, 2, 3, 4, 5) | |
scala> newQ.take(3) | |
res0: scala.collection.mutable.Queue[Int] = Queue(1, 2, 3) | |
scala> newQ |