





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Economics 101 graphics to reference from
Typology: Summaries
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















Created by Nishant Kheterpal and Jessica Hu; contributions by Jonathan Ferrari, Edwin Vargas and Bing Concepcion Updated and maintained by Marissa Lumpkin and Isaac Chung
Detailed Python Reference Sheet Abbreviated Reference Sheet Table Functions and Methods Column Operations Row Operations Data Manipulation Visualization Table .where Predicates Array Functions and Methods String Methods Miscellaneous Functions Histogram Bounds Language JupyterHub Keyboard Shortcuts
For Fall 2025, students will receive an abbreviated reference sheet for exams.
Past Midterm Reference Sheet
In the examples in the left column, np refers to the NumPy module, as usual. Everything else is a function, a method, an example of an argument to a function or method, or an example of an object we might call the method on. For example, tbl refers to a table, array refers to an array, str refers to a string, and num
refers to a number. array.item(0) is an example call for the method item, and in that example, array is the name previously given to some array.
Name Descripti on
Input Output
Table() (^) Create an empty table, usually to extend with data (Ch 6)
None Table: an empty table
Table().read_table (filename)
Create a table from a data file (Ch 6)
string: name of the file
Table with the contents of the data file tbl.num_rows (^) Compute the number of rows in a table (Ch 6)
None int: number of rows in the table
tbl.num_columns (^) Compute the number of
None int: number of columns
tbl.show(n) (^) Display n rows of a table. If no argumen t is specified , defaults to displayin g the entire table. (Ch 6.1)
(Optional) int: number of rows you want to display
None: displays a table with n rows
Name Description Input Output
tbl.column(column_nam e_or_index)
The values of a column (an array) (Ch 6 )
string or int: column name or index
array: values in that column
tbl.with_columns(name , values) tbl.with_columns(n1, v1, n2, v2, ...)
A table with an additional or replaced column or columns. name is a string for the name of a column,
string: name of the new column;
Table: a copy of the original Table with the new column s added
values is an array (Ch 6)
tbl.select(col1, col2, ...)
Create a copy of a table with only some of the columns. Each column is the column name or index. (Ch 6 )
string or int: column name(s ) or index(e s)
Table with the selecte d column s
tbl.drop(col1, col2, ...)
Create a copy of a table without some of the columns. Each column is the column name or index. (Ch 6 )
string or int: column name(s ) or index(e s)
Table without the selecte d column s
h e o ri gi n al t a bl e w it h o nl y t h e r o w s t h a t m a t c h t h e p r
e di c a t e
tbl.take( row_indic es)
A table with only the rows at the given indices. row_indices is either an array of indices or an integer corresponding to one index. (Ch 6.2)
array of ints: indices of rows to include in the Table or int: index of the row to include
a bl e: a c o p y o f t h e o
ri gi n al t a bl e w it h o nl y t
gi n al w it h t h e c o
lu m n s o rt e d
tbl.row(r ow_index)
Accesses the row of a table by taking the index of the row as its argument. Note that rows are in general not arrays, as their elements can be of different types. However, you can use .item to access a particular element of a row using row.item(label). (Ch 17.3)
int: row index R o w o bj e c t w it h t h e v al u
e s o f t h e r o w a n d
la b el s o f t h e c o
rr e s p o n di n g c o lu m
o bj e c t s
tbl.sampl e(k) tbl.sampl e(k, with_repl acement)
A new table where k rows are randomly sampled from the original table; by default, k=tbl.num_rows. Default is with replacement. For sampling without replacement, use argument with_replacement= False. For a non-uniform sample, provide a third argument weights=distribut ion where distribution is an array or list containing the probability of each row. (Ch 10)
a bl e: a n e w t a
bl e w it h k r o w s
Name Description Input Output
tbl.apply(f unction)
tbl.apply(f unction, col1, col2, ...)
Returns an array of values resulting from applying a function to each item in a column. (Ch 8.1)
function: function to apply to column
(Optiona l) string or int: name or index of the column to apply function to (if you have multiple columns , the respecti ve column’ s values will be passed as the corresp onding argume nt to the function ), and if there is no
array: contains an element for each value in the original column after applying the function to it
tbl.pivot(c ol1, col2)
tbl.pivot(c ol1, col2, values, collect)
A pivot table where each unique value in col1 has its own column and each unique value in col has its own row. Count or aggregate values from a third column, collect with some function. Default values and collect return counts in cells. (Ch 8.3)
(Optiona l) string or int: name or index of column that describe s the
Table: a new table reshaped so that unique values of col1 form columns, and unique values of col2 form rows. Optionally fills with aggregated values from another column.
values of cell
(Optiona l) function: how the values are collecte d (e.g. sum or np.mea n)
tblA.join(c olA, tblB, colB)
tblA.join(c olA, tblB)
Generate a table with the columns of tblA and tblB, containing rows for all values of a column that appear in both tables. Default colB is colA. colA and colB must be strings specifying column names. (Ch 8.4)
(Optiona l) string: if column names are different
Table: a new table with matched rows from tblA and tblB based on join columns
tbl.scatte r(x_column , y_column)
tbl.scatte r(x_column , y_column, fit_line)
Draws a scatter plot consisting of one point for each row of the table. Note that x_column and y_column must be strings specifying column names. Include optional argument fit_line=True if you want to draw a line of best fit for each set of points. (Ch 7)
None: draw s a scatt er plot
tbl.plot(x _column)
tbl.plot(x _column, y_column)
Draw a line graph consisting of one point for each row of the table. If you only specify one column, it will plot the rest of the columns on the y-axis as different colored lines. (Ch 7)
None: draw s a line graph
tbl.barh(c ategories)
tbl.barh(c ategories, values)
Displays a bar chart with bars for each category in a column, with length proportional to the corresponding frequency. values argument unnecessary if table has only a column of
None: draw s a bar chart
categories and a column of values. (Ch 7.1)
corresponding categories
tbl.hist(c olumn, unit, bins, group)
Generates a histogram of the numerical values in a column. unit and bins are optional arguments, used to label the axes and group the values into intervals (bins), respectively. Bins have the form [a, b), where a is included in the bin and b is not. (Ch 7.2)
None: draw s a histo gram
Table .where Predicates
Any of these predicates can be negated by adding not_ in front of them, e.g. are.not_equal_to(x) or are.not_containing(S).
Predicate Descriptio n are.equal_to(x) (^) Equal to x