{data dendrites} exploring data science with Python et al.

Pass the arguments, please

According to Julia documentation...

It is [...] worth emphasizing that functions should take arguments, instead of operating directly on global variables (aside from constants like pi).

Let's see if there is a difference in runtime depending on whether a function takes arguments, takes globals, or uses internal variables (the latter may not be a very fair comparison in this case).


FizzBuzz in Julia — using ternary operator

The rules are well-known: Print numbers from 1 to N (usually 100). If a number is divisible by 3, print "Fizz"; if it's divisible by 5, print "Buzz"; if it's divisible by both, print "FizzBuzz"; if neither, print the number.

This is obviously a very easy problem, but this is an opportunity to show the use of Julia's ternary operator (?):


Finding probability of twin stars

Generate num stars on a field of (x,y,z) = [low:high] and find all twin stars (those within min_d of each other).


Fixing WiFi connectivity on Linux

After I switched to Linux (Mint 17.1), I've been experiencing horrible WiFi connectivity. At Starbucks or a local library, where the connection strength is (apparently) better, I could connect easily, but at home my laptop could not connect at all, while my wife's Windows-running laptop (or my phone) had no problem, e.g., streaming.

Finally I decided to search for my WiFi card:

$ lspci
...
02:00.0 Network controller: Intel Corporation Centrino Advanced-N 6235 (rev 24)

Some online search revealed a common problem with this controller that can be fixed with:

$ echo options iwlwifi 11n_disable=1 | sudo tee /etc/modprobe.d/51-disable-6235-11n.conf

Which worked as a charm. Now I can connect even with a weak WiFi signal.


replace( ) for DataFrames

In Python/Pandas we have:

Output:

before: 
|   | icecream | miles    | something | opinion |
|---|----------|----------|-----------|---------|
| 1 | 40920    | 8.326976 | 0.953952  | 3       |
| 2 | 14488    | 7.153469 | 1.673904  | 2       |
| 3 | 26052    | 1.441871 | 0.805124  | 1       |

after:
|   | icecream | miles    | something | opinion |
|---|----------|----------|-----------|---------|
| 1 | 40920    | 8.326976 | 0.953952  | good    |
| 2 | 14488    | 7.153469 | 1.673904  | OK      |
| 3 | 26052    | 1.441871 | 0.805124  | bad     |

Julia's equivalent (I don't know yet if this function is already implemented):