Lecture 12
Table examples
DATA 8
Spring 2019
Slides created by John DeNero (denero@berkeley.edu) and Ani Adhikari (adhikari@berkeley.edu)
Announcements
Combining Table Methods
Important Table Methods
t.select(column, …) or t.drop(column, …)
t.take([row, …]) or t.exclude([row, …])
t.sort(column, descending=False, distinct=False)
t.where(column, are.condition(...))
t.apply(function, column, …)
t.group(column) or t.group(column, function)
t.group([column, …]) or t.group([column, …], function)
t.pivot(cols, rows) or t.pivot(cols, rows, vals, function)
t.join(column, other_table, other_table_column)
Bikes
(Demo)
Maps
(Demo)
Maps
A table containing columns of latitude and longitude values can be used to generate a map of markers
Applies to all features:
color='blue'
size=200
_______.map_table(table, ...)
Either Marker or Circle
Column 0: latitudes
Column 1: longitudes
Column 2: labels
Column 3: colors
Column 4: sizes
Review
Spring 2016 Midterm, Q2(b)
(Demo)
Advanced Where (Optional)
Comparison Operators
The result of a comparison expression is a bool value
x = 2 y = 3
x > 1 x > y y >= 3
x == y x != 2 2 < x < 5
Assignment statements
Comparison expressions
(Demo)
t.where(array_of_bool_values) returns a table with only the rows of t for which the corresponding bool is True.