In [2]:
# Following tutorial at http://data8.org/datascience/tutorial.html

from datascience import Table

# HIDDEN

import matplotlib
matplotlib.use('Agg')
from datascience import Table
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('fivethirtyeight')

In [3]:
t = Table().with_columns([
        'letter', ['a', 'b', 'c', 'z'],
        'count', [9, 3, 3, 1],
        'points', [1, 2, 2, 10]
    ])

print(t)


letter | count | points
a      | 9     | 1
b      | 3     | 2
c      | 3     | 2
z      | 1     | 10

In [4]:
Table.read_table('sample.csv')


Out[4]:
x y z
1 10 100
2 11 101
3 12 102

In [5]:
Table.read_table('http://data8.org/textbook/notebooks/sat2014.csv')


Out[5]:
State Participation Rate Critical Reading Math Writing Combined
North Dakota 2.3 612 620 584 1816
Illinois 4.6 599 616 587 1802
Iowa 3.1 605 611 578 1794
South Dakota 2.9 604 609 579 1792
Minnesota 5.9 598 610 578 1786
Michigan 3.8 593 610 581 1784
Wisconsin 3.9 596 608 578 1782
Missouri 4.2 595 597 579 1771
Wyoming 3.3 590 599 573 1762
Kansas 5.3 591 596 566 1753

... (41 rows omitted)


In [13]:
t = Table().with_columns({
        'letter': ['a', 'b', 'c', 'z'],
        'count':  [  9,   3,   3,   1],
        'points': [  1,   2,   2,  10],
    })

print(t)


count | letter | points
9     | a      | 1
3     | b      | 2
3     | c      | 2
1     | z      | 10

In [14]:
t


Out[14]:
count letter points
9 a 1
3 b 2
3 c 2
1 z 10

In [15]:
t.column('letter')


Out[15]:
array(['a', 'b', 'c', 'z'], 
      dtype='<U1')

In [16]:
t.column(1)


Out[16]:
array(['a', 'b', 'c', 'z'], 
      dtype='<U1')

In [17]:
t['letter']


Out[17]:
array(['a', 'b', 'c', 'z'], 
      dtype='<U1')

In [18]:
t[1]


Out[18]:
array(['a', 'b', 'c', 'z'], 
      dtype='<U1')

In [19]:
t.rows


Out[19]:
Rows(count | letter | points
9     | a      | 1
3     | b      | 2
3     | c      | 2
1     | z      | 10)

In [20]:
t.rows[0]


Out[20]:
Row(count=9, letter='a', points=1)

In [21]:
t.row(0)


Out[21]:
Row(count=9, letter='a', points=1)

In [23]:
second = t.rows[1]
second


Out[23]:
Row(count=3, letter='b', points=2)

In [24]:
second[0]


Out[24]:
3

In [25]:
second[1]


Out[25]:
'b'

In [26]:
t.num_rows


Out[26]:
4

In [27]:
t


Out[27]:
count letter points
9 a 1
3 b 2
3 c 2
1 z 10

In [ ]: