Question: I need help with my Python homework. I am stuck on how to get the two averages to compare them. There are two excel files

I need help with my Python homework. I am stuck on how to get the two averages to compare them. There are two excel files that have been turned into arrays. Just not sure how to calculate the averages.

I need help with my Python homework. I am stuck on howto get the two averages to compare them. There are two excelfiles that have been turned into arrays. Just not sure how tocalculate the averages. Load libraries H \#\# read excel files import pandas

Load libraries H \#\# read excel files import pandas as pd \#\# numerical operators import numpy as np \#\# plot functions import matplotlib.pyplot as plt \#\# inline plotting (i.e., show plots in notebook) \%matplotlib notebook \#\# Read the Excel file containing the annual and global mean temperature from year 850 to 1849 df850_1849 = pd.read_excel ('aaveTS.cesmLME.0850-1849.001.xlsx') \#\# Read column "aaveTS" and convert the Pandas dataframe to a numpy array aaveTS850_1849 =np.array( df850_1849['aaveTS' ]) \#\#\# \#\#\# \#\#\# \#\#\# \#\#\# \#\#\# \#\# Read the Excel file containing the annual and global mean temperature from year 2006 to 2100 df2006_2100= pd.read_excel('aaveTS.cesmLME.2006-2100.002.xlsx') \#\# Read column "aaveTS" and convert the Pandas dataframe to a numpy array Workspace 1: Function that calculates the mean of an array The mean () of an array x with length N (i.e., the number of elements in x is N ) is defined as: =N1i=0N1xi Exercise: Complete the function (1) Create a variable mu that is equal to the sum of the elements in variable x divided by the number of elements in x Hint 1: use to calculate the sum of all elements in x https:/umpy.org/doc/stable/reference/generatedumpy.sum.html Hint 2: Use function len() to calculate the number of elements in x https://docs.python.org/3/library/functions.html\#len Nothing will be printed to the screen when you run this function! M def my_mean(x): \#\# Ex 1: Calculate the mean (mu) of the input array x \#\# hint, mu=( sum of x)/ number of elements in x mu=npsum(x)/N \#\# Return variable mu from the function return mu \#\# Ex 3: Print variables my_mu and npmu to the screen print( '\my_mu:') print(' np_mu:') \#\# Ex 4: Print the ratio of variables my_mu and npmu to the screen print(' The ratio of my_mu / np_mu:') \my_mu

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!