<jupyter_start><jupyter_text>D1: Determine the Summary Statistics for June<jupyter_code># 2. Write a query that filters the Measurement table to retrieve the temperatures for the month of June. 
june_results = session.query(Measurement).filter(extract('month', Measurement.date) == 6).all()

#  3. Convert the June temperatures to a list.
june_results_list = [temp.tobs for temp in june_results]

# 4. Create a DataFrame from the list of temperatures for the month of June. 
df = pd.DataFrame(june_results_list, columns=['June Temps'])

# 5. Calculate and print out the summary statistics for the June temperature DataFrame.
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_results = session.query(Measurement).filter(extract('month', Measurement.date) == 12).all()

# 7. Convert the December temperatures to a list.
dec_results_list = [temp.tobs for temp in dec_results]

# 8. Create a DataFrame from the list of temperatures for the month of December. 
df = pd.DataFrame(dec_results_list, columns=['December Temps'])

# 9. Calculate and print out the summary statistics for the Decemeber temperature DataFrame.
df.describe()<jupyter_output><empty_output><jupyter_text>Additional Queries  June Rainfall<jupyter_code>june_results = session.query(Measurement).filter(extract('month', Measurement.date) == 6).all()
june_results_list = [rain.prcp for rain in june_results]
df = pd.DataFrame(june_results_list, columns=['June Rainfall'])
df.describe()<jupyter_output><empty_output><jupyter_text>December Rainfall<jupyter_code>dec_results = session.query(Measurement).filter(extract('month', Measurement.date) == 12).all()
dec_results_list = [rain.prcp for rain in dec_results]
df = pd.DataFrame(dec_results_list, columns=['December Rainfall'])
df.describe()<jupyter_output><empty_output><jupyter_text>Average Temperature Overall<jupyter_code>ann_temp_results = session.query(Measurement).filter(extract('month', Measurement.date) >0).all()
ann_temp_results_list = [temp.tobs for temp in ann_temp_results]
df = pd.DataFrame(ann_temp_results_list, columns=['Annual Temperatures'])
df.describe()<jupyter_output><empty_output><jupyter_text>Annual rainfall Describe<jupyter_code>ann_rain_results = session.query(Measurement).filter(extract('month', Measurement.date) >0).all()
ann_rain_results_list = [rain.prcp for rain in ann_rain_results]
df = pd.DataFrame(ann_rain_results_list, columns=['Annual Rainfall'])
df.describe()<jupyter_output><empty_output><jupyter_text>Plot annual Temperatures<jupyter_code>ann_results = session.query(Measurement.date, Measurement.tobs).all()
prev_year = dt.date(2017, 8, 23)

# Calculate the date one year from the last date in data set.
prev_year = dt.date(2017, 8, 23) - dt.timedelta(days=365)

# Perform a query to retrieve the data and precipitation scores
ann_results = session.query(Measurement.date, Measurement.tobs).filter(Measurement.date >= prev_year).all()

df = pd.DataFrame(ann_results, columns=['date','temperature'])
df.set_index(df['date'], inplace=True)
df.to_string(index=False)
df = df.sort_index()
ax = df.plot(figsize=(20,6))
x_axis_session = session.query(Measurement.date).filter(Measurement.date >= prev_year).all()
# Convert to a list.
x_axis = [temp.date for temp in x_axis_session]
y_axis_session = session.query(Measurement.tobs).filter(Measurement.date >= prev_year).all()
# Convert to a list.
y_axis = [temp.tobs for temp in y_axis_session]
fig, ax = plt.subplots(figsize=(20,6))
ax.scatter(x_axis, y_axis)<jupyter_output><empty_output><jupyter_text>Plot annual rainfall<jupyter_code>ann_results = session.query(Measurement.date, Measurement.prcp).all()
prev_year = dt.date(2017, 8, 23)

# Calculate the date one year from the last date in data set.
prev_year = dt.date(2017, 8, 23) - dt.timedelta(days=365)

# Perform a query to retrieve the data and precipitation scores
ann_results = session.query(Measurement.date, Measurement.prcp).filter(Measurement.date >= prev_year).all()

df = pd.DataFrame(ann_results, columns=['date','precipitation'])
df.set_index(df['date'], inplace=True)
df.to_string(index=False)
df = df.sort_index()
ax = df.plot(figsize=(20,6))
x_axis_session = session.query(Measurement.date).filter(Measurement.date >= prev_year).all()
# Convert to a list.
x_axis = [rain.date for rain in x_axis_session]
y_axis_session = session.query(Measurement.prcp).filter(Measurement.date >= prev_year).all()
# Convert to a list.
y_axis = [rain.prcp for rain in y_axis_session]
fig, ax = plt.subplots(figsize=(20,6))
ax.scatter(x_axis, y_axis)

plt.savefig("rainfall.png")
# Export CSV
# df.to_csv(r"C:\my house\bootcamp\9_SQL_Alchemy\surfs_up\csv\annual_rain.csv", header = True)<jupyter_output><empty_output><jupyter_text>Choose your Month for Rain<jupyter_code># Prompt the user to enter month for rainfall 
month_rain = float(input("What month do you want rainfall stats for? Enter # for month e.g., 1 = January  "))
months = {1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December"}
# if month_rain in months:
results = session.query(Measurement).filter(extract('month', Measurement.date) == month_rain).all()
results_list = [rain.prcp for rain in results]
df = pd.DataFrame(results_list, columns=[months[month_rain]])
df.describe()
# else:
#     print('That month number is invalid.')<jupyter_output>What month do you want rainfall stats for? Enter # for month e.g., 1 = January  6<jupyter_text>Choose your Month for Temperatures¶<jupyter_code># Prompt the user to enter month for temperatures 
month_temp = float(input("What month do you want temperature stats for? Enter # for month e.g., 1 = January  "))
months = {1:"January", 2:"February", 3:"March", 4:"April", 5:"May", 6:"June", 7:"July", 8:"August", 9:"September", 10:"October", 11:"November", 12:"December"}
# if month_rain in months:
results = session.query(Measurement).filter(extract('month', Measurement.date) == month_temp).all()
results_list = [temp.tobs for temp in results]
df = pd.DataFrame(results_list, columns=[months[month_temp]])
df.describe()
# else:
#     print('That month number is invalid.')<jupyter_output>What month do you want temperature stats for? Enter # for month e.g., 1 = January  12
{'fraction_non_alphanumeric': 0.13088189467123715, 'fraction_numerical': 0.015892801495793082, 'mean_word_length': 6.7244283995186525, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 47, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '480204', 'license': 'MIT', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2081, 'n_words': 536, 'path': 'SurfsUp_Challenge.ipynb', 'repo_name': 'honoruru/surfs_up', 'size': '6418'}