Economics 101 graphics to reference, Summaries of Economics

Economics 101 graphics to reference from

Typology: Summaries

2024/2025

Uploaded on 12/16/2025

alex-q4c
alex-q4c 🇺🇸

5 documents

1 / 29

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Detailed Python Reference Sheet
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
TABLE OF CONTENTS
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
Abbreviated Reference Sheet
For Fall 2025, students will receive an abbreviated reference sheet for exams.
Past Midterm Reference Sheet
Table Functions and Methods
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d

Partial preview of the text

Download Economics 101 graphics to reference and more Summaries Economics in PDF only on Docsity!

Detailed Python Reference Sheet

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

TABLE OF CONTENTS

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

Abbreviated Reference Sheet

For Fall 2025, students will receive an abbreviated reference sheet for exams.

Past Midterm Reference Sheet

Table Functions and Methods

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

Column Operations

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;

  1. array: values in that 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

T

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)

  1. int: sample size
  2. (Optional) boolean: default with_replacem ent=True

T

a bl e: a n e w t a

bl e w it h k r o w s

Data Manipulation

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)

  1. string or int: name or index of column whose unique values will make up columns of pivot table
  2. string or int: name or index of column whose unique values will make up rows of pivot table

(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)

  1. string: name of a column in tblA with values to join on
  2. Table: other Table

(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)

  1. string: name of the column on the x-axis
  2. string: name of the column on the y-axis
  3. (Optional) fit_line=Tr ue

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)

  1. string: name of the column on the x-axis
  2. string: name of the column on the y-axis

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

  1. string: name of the column with categories
  2. (Optional) string: the name of the column with values for

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)

  1. string: name of the column with numerical values
  2. (Optional) string: units of x-axis
  3. (Optional) array of ints/floats denoting bin boundaries
  4. (Optional) string: name of categorical column to draw separate overlaid histograms for

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