<jupyter_start><jupyter_text>D1: Determine the Summary Statistics for June<jupyter_code># 1. Import the sqlalchemy extract function.
from sqlalchemy import extract

# 2. Write a query that filters the Measurement table to retrieve the temperatures for the month of June. 
june_temps = session.query(Measurement).filter(extract('month', Measurement.date) == 6)
#  3. Convert the June temperatures to a list.
june_temps_list = [temp.tobs for temp in june_temps]
print(np.mean(june_temps_list))
# 4. Create a DataFrame from the list of temperatures for the month of June. 
june_df = pd.DataFrame(june_temps_list, columns=["temps"])
# 5. Calculate and print out the summary statistics for the June temperature DataFrame.
june_df.describe()<jupyter_output><empty_output><jupyter_text>D2: Determine the Summary Statistics for December<jupyter_code># 6. Write a query that filters the Measurement table to retrieve the temperatures for the month of December.
dec_temps = session.query(Measurement).filter(extract('month', Measurement.date) == 12)
# 7. Convert the December temperatures to a list.
dec_temps_list = [temp.tobs for temp in dec_temps]
print(np.mean(dec_temps_list))
# 8. Create a DataFrame from the list of temperatures for the month of December. 
dec_df = pd.DataFrame (dec_temps_list, columns =["temps"])
dec_df
# 9. Calculate and print out the summary statistics for the Decemeber temperature DataFrame.
dec_df.describe()
#see first and last data entry and counts by station 
session.query(Measurement.station, func.min(Measurement.date), func.max(Measurement.date), func.count(Measurement.station)).\
    group_by(Measurement.station).all()
#show min and max and mean tob by station 
session.query(Measurement.station, func.min(Measurement.tobs), func.max(Measurement.tobs), func.avg(Measurement.tobs)).\
group_by(Measurement.station).all()
# Write a function called `calc_temps` that 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. Let's look at only the most recent year grouped by station. 
def calc_temps(start_date, end_date):
    return session.query(Measurement.station, func.min(Measurement.tobs), func.max(Measurement.tobs), func.avg(Measurement.tobs)).\
            filter(Measurement.date >= start_date).filter(Measurement.date <= end_date).group_by(Measurement.station).all()
results = (calc_temps('2017-01-01','2017-12-31'))
most_recent_year_df = pd.DataFrame(results, columns=['station','min', 'max', 'mean'])
most_recent_year_df
#Precipitation Day over Day month of June 2016 
results = session.query(Measurement.date, Measurement.prcp).filter(extract('month', Measurement.date) == 6).filter(Measurement.date >= '2016-06-01').filter(Measurement.date <= '2016-06-31')
df = pd.DataFrame(results, columns=['date','precipitation'])
df.set_index(df['date'], inplace=True)
# Sort the dataframe by date
df = df.sort_index()
# Use Pandas Plotting with Matplotlib to plot the data
df.plot()
#Precipitation Day over Day month of Dec 2016
results = session.query(Measurement.date, Measurement.prcp).filter(extract('month', Measurement.date) == 12).filter(Measurement.date >= '2016-12-01').filter(Measurement.date <= '2016-12-31')
df = pd.DataFrame(results, columns=['date','precipitation'])
df.set_index(df['date'], inplace=True)
# Sort the dataframe by date
df = df.sort_index()
# Use Pandas Plotting with Matplotlib to plot the data
df.plot()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11729280183538858, 'fraction_numerical': 0.020934901061084026, 'mean_word_length': 5.879684418145956, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '133691', 'license': 'MIT', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1068, 'n_words': 325, 'path': 'SurfsUp_Challenge_starter_code.ipynb', 'repo_name': 'cfusco77/surfs_up', 'size': '3487'}