Download (right-click, save target as ...) this page as a jupyterlab notebook from: Lab11-TH


Laboratory 11: Dataframes (Continued)

LAST NAME, FIRST NAME

R00000000

ENGR 1330 Laboratory 11 - Homework

Preamble script block to identify host, user, and kernel


Exercise 1:

Follow the steps below:

  1. STEP 0: install necessary libraries (numpy and pandas)
  2. STEP 1: There are 8 digits in your R#. Define a 2x4 array with these 8 digits, name it "Rarray", and print it
  1. STEP 2: Find the maximum value of the "Rarray" and its position
  1. STEP 3: Sort the "Rarray" along the rows, store it in a new array named "Rarraysort", and print the new array out
  1. STEP 4: Define and print a 4x4 array that has the "Rarray" as its two first rows, and "Rarraysort" as its next rows. Name this new array "DoubleRarray"
  1. STEP 5: Slice and print a 4x3 array from the "DoubleRarray" that contains the last three columns of it. Name this new array "SliceRarray".
  1. STEP 6: Define the "SliceRarray" as a panda dataframe:
    • name it "Rdataframe",
    • name the rows as "Row A","Row B","Row C", and "Row D"
    • name the columns as "Column 1", "Column 2", and "Column 3"
  1. STEP 7: Print the first few rows of the "Rdataframe".
  1. STEP 8: Create a new dataframe object ("R2dataframe") by adding a column to the "Rdataframe", name it "Column X" and fill it with "None" values. Then, use the appropriate descriptor function and print the data model (data column count, names, data types) of the "R2dataframe"
  1. STEP 9: Replace the 'None' in the "R2dataframe" with 0. Then, print the summary statistics of each numeric column in the data frame.
  1. STEP 10: Define a function based on the equation below:
$$ y = x^2 - 5x +7 $$

apply the function to the entire "R2dataframe", store the results in a new dataframe ("R3dataframe"), and print the results and the summary statistics again.

  1. STEP 11: Print the number of occurrences of each unique value in "Column 3"
  1. STEP 12: Sort the data frame with respect to "Column 1" with a descending order and print it
  1. STEP 13: Write the final format of the "R3dataframe" on a CSV file, named "Rfile.csv"
  1. STEP14: Read the "Rfile.csv" and print its content.
    ** Make sure to attach the "Rfile.csv" file to your submission.

Exercise 2:

Precipitation records for Lubbock from 1895 to 2019 for the month of October is located in the file http://54.243.252.9/engr-1330-webroot/4-Databases/Lubbockdata.csv. Using this file:

  1. Download the file and read it into a dataframe
  2. Describe the entire data set. [Script]
  3. Produce a plot of year vs precipitation. [Script + Plot 1: data==blue]
  4. Split the data into two parts at the year 1960. [Script]
  5. Describe the two data series you have created. [Script]
  6. Plot the two series on the same plot. [Script + Plot 2: data1==blue, data2==green]