Here are a few useful things to know about Python

All touched on in Class 1


In [ ]:
# assignment
x = 0

In [ ]:
# conditional statements (and print output)
if x > 0:
    print 'positive'
elif x == 0:
    print 'zero'
else:
    print 'negative'

In [ ]:
# functions
def my_func(y):
    return y**2
my_func(2)

In [ ]:
# loops
for x in range(10):
    print my_func(x),

In [ ]:
# DataFrames and reading csvs
import pandas as pd
df = pd.read_csv('data/weather-numeric.csv')

In [ ]:
df.index

In [ ]:
df.columns

In [ ]:
print df

In [ ]:
df.humidity

In [ ]:
df.loc[12]

In [28]:
from ipynb_style import presentation
presentation()


Out[28]:

In [ ]: