Title | Data 8 Midterm Reference Sheet |
---|---|
Course | Introduction to Data Science |
Institution | University of California, Berkeley |
Pages | 2 |
File Size | 63.8 KB |
File Type | |
Total Downloads | 114 |
Total Views | 168 |
Cheat sheet of code used...
Data 8 Midterm Reference Guide — Page 1 Statements
more_than_1 = 2 + 3 Any expression
Name
● Statements don't have a value; they perform an action ● An assignment statement changes the meaning of the nam left of the = symbol ● The name is bound to a value (not an equation)
Comparisons ● ● ● ●
< and > mean what you expect (less than, greater than) = == means "equal"; != means "not equal" Comparing strings compares their alphabetical order
Arrays - sequences of the same type that can be manipulated ● Arithmetic and comparisons are applied to each element of individually ○ make_array(1,2,3) ** 2 # array([1, 4, 9]) ● Elementwise operations can be done on arrays of the same ○ make_array(1,2) * make_array(5,4) # array([5, Defining a Function d f f ti
(
1
2
)
Data 8 Midterm Reference Guide — Page 2 In the examples in the left column, np refers to the NumPy modu method, or an example of an object we might call the method on array.item(0) is an example call for the method item, and in t
Example function call
Value of a ca
max(array); min(array)
Maximum or mi
sum(array)
Sum of all elem
len(array)
Length (num ele
round(num); np.round(array)
The nearest inte
abs(num); np.abs(array)
The absolute va
np.average(array), np.mean(array)
The average of
np.arange(start, stop, step) np.arange(start, stop) np.arange(stop)
An array of num When start an
array.item(index)
The item in the
np.append(array, item)
A copy of the ar
np.random.choice(array, n)
An item selecte replacement is
np.ones(n)
An array of leng
np.diff(array)
An array of leng
np.count_nonzero(array)
An integer corre
sample_proportions(sample_size,
An array of prop...