Sunday, October 15, 2017

DG 01 Tools

dg13-01_ToolsOverview
In [2]:
things = ["First Name", "Last Name"]

def snakify(txt):
    "return string in snake_case"
    return txt.replace(" ","_").lower()

print ([snakify(thing) for thing in things])


snakify( "My Name is Greg" )
['first_name', 'last_name']
Out[2]:
'my_name_is_greg'
In [3]:
# try these out too
!dir
 Volume in drive C is Windows
 Volume Serial Number is 64AF-3261

 Directory of C:\Users\Yantrajaal\pyWork\Machine Learning

12-10-2017  13:47    <DIR>          .
12-10-2017  13:47    <DIR>          ..
12-10-2017  13:47    <DIR>          .ipynb_checkpoints
12-10-2017  13:15           103,052 ML-IrisData-.ipynb
12-10-2017  13:47        10,859,074 Unconfirmed 952229.crdownload
12-10-2017  13:47                72 Untitled.ipynb
               3 File(s)     10,962,198 bytes
               3 Dir(s)  844,940,222,464 bytes free
In [4]:
foo = ! echo hello, world
foo
Out[4]:
['hello, world']
In [ ]:
# download salary_data.csv save contents to 
# a local file in the same directory as this notebook
!curl http://www.justinmrao.com/salary_data.csv >> ./salary_data.csv
In [1]:
import pylab as pl
X = range(10)
y = range(11,21)
pl.scatter(X,y, c='r')
pl.show()
print
Out[1]:
<function print>
In [3]:
%%javascript

function say_hi ( ) {
    alert("Hello, World");
};

say_hi();
console.log("Welcome!");
In [4]:
from IPython.display import Image
Image("http://ipython.org/_static/IPy_header.png")
Out[4]:
In [5]:
from IPython.lib.display import YouTubeVideo
YouTubeVideo('SncapPrTusA', width=680, height=400)
Out[5]:
In [6]:
"""example taken from Scipy and NumPy by Eli Bressert (p. 6)"""
import numpy as np

def list_times(alist, scalar):
    for i, val in enumerate(alist):
        alist[i] = val * scalar
    return alist
In [ ]:
 

No comments:

Post a Comment