Now produce local fits. A very simple approach is to compute an
average across a full year, with the date you want to estimate right in the middle.
(Note: depending on how you code this, you may have to make reasonable
adjustments towards the start and the end of your time range.)
To do this, you should first write a function
def local_fit(data,xmin,xmax):
# add your code
return yaverage
that takes a takes as input a pandas dataframe with two numerical columns
containing x and y values, and two values xmin and xmax and returns the average
over all values of y for which xmin < x < xmax.
As an example,
local_fit(CH4_df[[“decimal”,”average”]],2000,2001)
should give a methane concentration of around 1773 ppb
Data science – python Q
Share