Assignment 2
BUSI 520: Python for Business Research
Jones Graduate School of Business
Rice University
Numpy
- Creating Arrays:
- Create a one-dimensional array of integers from 0 to 9.
- Create a two-dimensional array of zeros with shape (5, 5).
- Create a three-dimensional array of ones with shape (2, 3, 4).
- Manipulating Arrays:
- Reshape the above two-dimensional array to a one-dimensional array.
- Stack two arrays horizontally and vertically.
- Split a given array into multiple sub-arrays.
- Flatten a multi-dimensional array.
- Expand the dimensions of a one-dimensional array.
- Array Indexing:
- Extract the third and fifth elements from a one-dimensional array.
- Extract a 2x2 sub-matrix from a given two-dimensional array.
- Use boolean indexing to extract even numbers from an array.
- Arithmetic Operations:
- Perform element-wise addition, subtraction, multiplication, and division on two given arrays.
- Multiply a 2x3 matrix with a 1x3 matrix using broadcasting.
- Aggregation Functions:
- Calculate the sum, mean, standard deviation, and variance of a one-dimensional array.
- Find the minimum and maximum values in a one-dimensional array.
- Repeat (a) and (b) along a single axis of a two-dimensional array.
- Linear Algebra:
- Transpose a matrix
- Multiply two matrices.
- Compute the dot product of two vectors.
- Calculate the determinant of a matrix.
- Compute the eigenvalues and eigenvectors of a matrix.
- Solve a system of linear equations using NumPy.
- Simulation:
- Simulate 100 steps of a random walk with standard normal innovations.
- Generate 1,000 simulations of the random walk from part (a). Compute the mean, median, and standard deviation of the terminal value across the 1,000 simulations.
Pandas
- Basics of pandas Series and DataFrames
- Create a series from a list of integers.
- Extract values at specific indices from the Series.
- Change the index of the series to alphabetical letters.
- Create a dataFrame from a dictionary of lists.
- Extract specific columns from the dataFrame.
- Add a new column to the dataFrame.
- Create a dataframe filled with random numbers.
- Basic DataFrame Operations:
- Calculate the summary statistics for a DataFrame column.
- Sort the dataFrame based on a specific column.
- Filter rows based on certain criteria.
- Replace specific values in a DataFrame.
- Rename columns.
- Map values in a column to other values using a dictionary.
- Missing values:
- Find all missing values in a DataFrame. b Fill missing values with zeros.
- Fill missing values in a column with the column’s mean value.
- Drop rows with missing data.
- Find duplicate rows.
- Drop all but the last row in each set of duplicate rows.
- Filtering and Aggregation:
- Using the ‘tips’ dataset, filter the rows where the total bill is greater than $10.
- Create a new column in the ‘tips’ dataset called ‘bill_per_person’ which is the total bill divided by the size of the party.
- Group by the ‘day’ column and compute the average total bill for each day.