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

Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
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...
# ArrayStack # TODO: push and pop using array stack with doubling technique. import numpy as...
# ArrayStack # TODO: push and pop using array stack with doubling technique. import numpy as np from future import print_function # Definisi class ArrayStack class ArrayStack(object): def __init__(self): self.data = np.zeros(20, dtype=np.int) self.count = 0 def isEmpty(self): pass # ubah saya def size(self): pass # ubah saya def push(self, obj): pass # ubah saya def pop(self): pass # ubah saya #-------------------------- # End of class if __name__ == "__main__": stack = ArrayStack() randn = np.random.permutation(1000) for i in range(1000):...
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...
In python import numpy as np Given the array b = np.arange(-6, 4) compute and print...
In python import numpy as np Given the array b = np.arange(-6, 4) compute and print 1.) The array formed by \(bi^2 - 1\), where the \(bi\) are the elements of the array b. 2.) The array formed by multiplying b with the scalar 100. 3.)The array formed by 2.0 b i in reverse order. (Note: the base 2.0 must be a floating point number; for integer values a ValueError: Integers to negative integer powers are not allowed. is raised.)...
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...
1 Linear Algebra in Numpy (1) Create a random 100-by-100 matrix M, using numpy method "np.random.randn(100,...
1 Linear Algebra in Numpy (1) Create a random 100-by-100 matrix M, using numpy method "np.random.randn(100, 100)", where each element is drawn from a random normal distribution. (2) Calculate the mean and variance of all the elements in M; (3) Use "for loop" to calculate the mean and variance of each row of M. (4) Use matrix operation instead of "for loop" to calculate the mean of each row of M, hint: create a vector of ones using np.ones(100, 1)?...
Generate a sample of 1000 random floating numbers (from 0 to 1) using numpy. Then plot...
Generate a sample of 1000 random floating numbers (from 0 to 1) using numpy. Then plot it and compare with a normal distribution plot close to that region (from 0 to 1) as well. Hint: Using Seaborn module
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.
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)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT