<jupyter_start><jupyter_text>Computing daily records(plot temperature data for a year by plotting, also, historical records, that is the most extreme temperatures achieved on that day of the year across all the available years.)1. Combining Boolean masks with logical operators2. Computing maxima and minima across a single dimension in a 2D array3. Plotting a shaded area with matplotlib To compute records, we will recast the temperature data in the form of a 2D array, where each row corresponds to a year and each column to a day.<jupyter_code>#Write a function to extract a single year of data

def selectyear(data,year):
    start = np.datetime64('{}'.format(year))
    end = start + np.timedelta64(1,'Y')
    #build the boolean mask by combining two conditions
    return data[(data['date'] >= start) & (data['date'] <= end)]['value']
selectyear(lihue_tmin,1951)
#to arrange all the years in a matrix, ignoring the extra day in leap years
#take only first 365 days

lihue_tmin_all = np.vstack([selectyear(lihue_tmin,year)[:365] for year in range(1951,2014+1)])
lihue_tmin_all
#verify the shape is correct

lihue_tmin_all.shape
#To use numpy to compute the maximum and minimum along its row

lihue_tmin_recordmin = np.min(lihue_tmin_all,axis=0)
lihue_tmin_recordmax = np.max(lihue_tmin_all,axis=0)
pp.plot(lihue_tmin_recordmax,'.')
# To build the plot, we also need a stacked array of all the tmax data

lihue_tmax_all = np.vstack([selectyear(lihue_tmax,year)[:365] for year in range(1951,2014+1)])
pp.figure(figsize=(12,4))

days = np.arange(1, 365+1)

#We are going to select year 2009 and plot against our records
#The matplotlib function to plot against a shaded area is fill_between
#It does need a 1-dimensional array for the horizontal direction. 
#We'll give this area an alpha value of .4, which makes it partly transparent. 
#Then, we'll plot the 2009 data against it.

pp.fill_between(days,np.min(lihue_tmin_all,axis=0),np.max(lihue_tmin_all,axis=0),alpha=0.4)
pp.plot(selectyear(lihue_tmin,2009))

pp.fill_between(days,np.min(lihue_tmax_all,axis=0),np.max(lihue_tmax_all,axis=0),alpha=0.4)
pp.plot(selectyear(lihue_tmax,2009))

pp.axis(xmax=365)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09621523027815777, 'fraction_numerical': 0.0364797081623347, 'mean_word_length': 5.813664596273292, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '567162', 'license': 'MIT', 'n_tokens_mistral': 799, 'n_tokens_neox': 740, 'n_words': 249, 'path': 'NumPy - Weather data Project/05 computing daily records.ipynb', 'repo_name': 'AryaDevops/Python-for-DataScience', 'size': '2193'}