<jupyter_start><jupyter_text>BONUS  Temperature Analysis I<jupyter_code>df = pd.read_csv("hawaii_measurements.csv")

df
df.date = pd.to_datetime(df.date,infer_datetime_format=True)
df
June_temps = df['date'].map(lambda x: x.month) == 6
June_TAVG = df[June_temps]["tobs"]

June_TAVG.mean()
Dec_temps = df['date'].map(lambda x: x.month) == 12
Dec_TAVG = df[Dec_temps]["tobs"]
Dec_TAVG.mean()
stats.ttest_ind(June_TAVG, Dec_TAVG)<jupyter_output><empty_output><jupyter_text>Temperature Analysis II<jupyter_code># This function called `calc_temps` will accept start date and end date in the format '%Y-%m-%d' 
# and return the minimum, average, and maximum temperatures for that range of dates
def calc_temps(start_date, end_date):
    """TMIN, TAVG, and TMAX for a list of dates.

    Args:
        start_date (string): A date string in the format %Y-%m-%d
        end_date (string): A date string in the format %Y-%m-%d
        
    Returns:
        TMIN, TAVE, and TMAX
    """
    
    return session.query(func.min(Measurement.tobs), func.avg(Measurement.tobs), func.max(Measurement.tobs)).\
        filter(Measurement.date >= start_date).filter(Measurement.date <= end_date).all()

# function usage example
# print(calc_temps('2012-02-28', '2012-03-05'))
trip_dates = '2017-05-30 to 2017-06-03'
trip_start_date = '2017-05-30'
trip_end_date = '2017-06-03'
trip_temps = calc_temps(trip_start_date, trip_end_date)
trip_temps
TMIN = trip_temps[0][0]
TAVG = trip_temps[0][1]
TMAX = trip_temps[0][2]

minplt = TAVG - TMIN
maxplt = TMAX - TAVG

YERR = np.array([[minplt], [maxplt]])

plt.bar(trip_dates, TAVG, yerr=YERR, color = 'orangered', alpha = .6)
plt.ylim(0, 100)
plt.xlim(-1.5, 1.5)
plt.title('Trip Avg Temp')
plt.ylabel('Temp (F)')
plt.grid(alpha=.3)<jupyter_output><empty_output><jupyter_text>Daily Rainfall Average<jupyter_code>#Calculate the rainfall per weather station using the previous year's matching dates.
yearly_rain = session.query(Station.station, Station.name, Station.latitude, Station.longitude,
                               Station.elevation, func.avg(Measurement.prcp)).\
    filter(Measurement.station == Station.station).\
    filter(func.strftime("%Y-%m-%d", Measurement.date) >= dt.date(2016, 8, 23)).group_by(Station.station).\
    order_by(func.avg(Measurement.prcp).desc()).all()

#load into a dataframe
rain_df = pd.DataFrame(yearly_rain, columns = ['Station', 'Name', 'Latitude', 'Longitude', 
                                                              'Elevation', 'Avg. Precipitation (in.)'])

rain_df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14602803738317757, 'fraction_numerical': 0.02881619937694704, 'mean_word_length': 4.158634538152611, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '434018', 'license': 'MIT', 'n_tokens_mistral': 1025, 'n_tokens_neox': 934, 'n_words': 193, 'path': 'Climate.ipynb', 'repo_name': 'MtMedina0017/SQLAlchemy-Challenge', 'size': '2568'}