Question

In: Computer Science

1) Load the data from lab6_precipitation.csv into a numpy array; 2) Make a numpy array with...

1) Load the data from lab6_precipitation.csv into a numpy array; 2) Make a numpy array with the years 1916-2016 and dtype=int; 3) Make a numpy array with the months 1-12 and dtype=int; 4) Print out the shape of the data array and the lengths of the years and month array. If the length of your year array does not equal the number of rows in your data array, or the length of your months array does not equal the number of columns in your data array, you have done something wrong!

Please just post the code for these functions.

Solutions

Expert Solution

# import necessary libraries
import pandas as pd
import numpy as np

# Question 1: Load the data into numpy array
data = pd.read_csv('lab6_precipitation.csv', header = None).to_numpy()

# Question 2 : Make a numpy array with the years 1916-2016 and dtype=int;
years = np.arange(start=1916, stop=2017)
#print(years);

# Question 3 : Make a numpy array with the months 1-12 and dtype=int;
months = np.arange(start=1, stop=13)
#print(months)

# Question 4: 4) Print out the shape of the data array and the lengths of the years and month array.
print('Data Array shape : '+str(data.shape))
print('Year Array Length : '+str(years.size))
print('Month Array Length : '+str(months.size))
#print(data)
if data.shape[0]!=years.size or data.shape[1]!=months.size:
    print('You have done something wrong!')

If you still have any queries, please feel free to post in comment box. I would be glad to help you.

If you like my explanation, please give a thumbs up. It really motivates us to provide a good quality work.


Related Solutions

Use NumPy to create a My_Array; a 3 by 3 array where in,m = n +...
Use NumPy to create a My_Array; a 3 by 3 array where in,m = n + m. (e.g., the first row first column would be 0+0=0, second row first column would be 1+0=1, etc). complete the following using NumPy: Compute the mean, median, range, and variance of this array Find the inverse or pseudo inverse Find the determinant Perform the following operations on My_Array Create My_1D_Array by reshaping My_Array into a 1-dimensional array Create a new array that is the...
Java program In the main(), create and load a 2-dimentional array to hold the following sales...
Java program In the main(), create and load a 2-dimentional array to hold the following sales data Number of Tacos Sold (hard code the data into the array when you create it) Truck3 Truck4 .    Truck5 Monday 250 334 229 Wednesday   390 145 298 Friday .    434 285 . 156 • Write a method to calculate the grand total of all Tacos sold Write a method to allow the user to enter a truck number and get the total...
Write a program using multiple functions. Make use of an array to store data Make use...
Write a program using multiple functions. Make use of an array to store data Make use of searching techniques Read data from a file Write data to a file Instructions: In this lab, you will be examining a set of stock collected over a twenty four day period. Be sure to make use of an array to store these stocks. You will be required to read in the data points from a file. Write a function to read in the...
Name the data type,value type and array size / name of the followings. 1) 20.4 2)...
Name the data type,value type and array size / name of the followings. 1) 20.4 2) a=5 3) [2 3 8] 4) ' 7 ' 5) ' abc' 6) pi 7) b=true 8) 20+2i 9) [ 'a' 'b' 'c' ] 10) [ 'a' ; 'b' ] 11) [1 2 ;4 5;7 8] 12) [20,21,22,23] 13) c= [a;b] 14) c= [b:a] 15) d=[b:a ; b:a] 16) magic(3) 17 uint8(20) 18) int8(d)
1. Write a Python program that performs the following: 2. Defines an array of integers from...
1. Write a Python program that performs the following: 2. Defines an array of integers from 1 to 10. The numbers should be filled automatically without the need for user inputs 3. Find the sum of the numbers that are divisible by 3 (i.e., when a number is divided by 3, the remainder is zero) 4. Swap the positions of the maximum and minimum elements in the array. First, you need to find the maximum element as shown in the...
Make assembly code that accomplishes the following: load a number into accumulator A 2. logical shift...
Make assembly code that accomplishes the following: load a number into accumulator A 2. logical shift right of A 3. If the carry bit of CCR sets (use instruction “bcs”), then steadily display a “1” on a seven- segment display block. 4. If the carry bit is not set, then steadily display a “0” on a seven-segment display block. 5. Change to another number and run the code, again, so that you can see either 1 or 0 displayed.
Write a program in C that declares the following array: int. array[] = { 1, 2,...
Write a program in C that declares the following array: int. array[] = { 1, 2, 4, 8, 16, 32 } Then write some code that accepts a number between 0 and 5 from the user and stores it in a variable called "index". Write some code that retrieves the item specified by the index, like this: int item = array[index]; Then write code that outputs the corresponding array entry based on the number the user entered. Example output: The...
1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array...
1.) Generate an array of 10 random numbers between 1 - 100 2.) Copy the array to a temp array 3.) Call each of the methods to sort (bubble, selection, insertion, quick, merge), passing it the array 4.) In-between the calls, you are going to refresh the array to the original numbers. 5.) Inside of each sorting method, you are going to obtain the nanoseconds time, before and after the method Subtract the before time from the after time to...
1)How does a.c. distribution differ from d.c. distribution ? 2.) What is the importance of load...
1)How does a.c. distribution differ from d.c. distribution ? 2.) What is the importance of load power factors in a.c. distribution ? 3). Describe briefly how will you solve a.c. distribution problems ? 4) difference between balanced and unbalanced load
An array A[0..n - 2] contains n-1 integers from 1 to n in increasing order. (Thus...
An array A[0..n - 2] contains n-1 integers from 1 to n in increasing order. (Thus one integer in this range is missing.) Design an algorithm in ​(Theta(log n)) to find the missing integer. Your algorithm should be given in pseudo code. For example, the array A could be {1, 2, 3, 4, 6, 7, 8, 9, 10} in which 5 is missing.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT