<jupyter_start><jupyter_text>Bonus: Temperature Analysis I<jupyter_code>import pandas as pd
from datetime import datetime as dt
from sqlalchemy import extract
import numpy as np

import sqlalchemy
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
# create engine to hawaii.sqlite
hawaii_database_path = "./Resources/hawaii.sqlite"
engine = create_engine(f"sqlite:///{hawaii_database_path}")
connector = engine.connect()
# Reflect an existing database into a new model
Base = automap_base()

# reflect the tables
Base.prepare(engine, reflect=True)
# View all of the classes that automap found
Base.classes.keys()
# Save references to each table
Measurement = Base.classes.measurement
Station = Base.classes.station
# Create our session (link) from Python to the DB
session = Session(engine)
# "tobs" is "temperature observations"
df = pd.read_csv('./Resources/hawaii_measurements.csv')
df.head()
# Convert the date column format from string to datetime
df['date']= pd.to_datetime(df['date'])
df.info()
# Set the date column as the DataFrame index
df = df.set_index('date')
df<jupyter_output><empty_output><jupyter_text>Compare June and December data across all years<jupyter_code>from scipy import stats
# Filter data for desired months
june_temp = session.query(Measurement).\
                filter(extract('month', Measurement.date) == 6).all()
june_temp_list = [temp.tobs for temp in june_temp]

december_temp = session.query(Measurement).\
                filter(extract('month', Measurement.date) == 12).all()
december_temp_list = [temp.tobs for temp in december_temp]
# Identify the average temperature for June
june_avg = np.mean(june_temp_list)
print(f"Average temperature for June: {june_avg}")
# Identify the average temperature for December
december_avg = np.mean(december_temp_list)
print(f"Average temperature for December: {december_avg}")
# Create collections of temperature data

# Run paired t-test
stats.ttest_ind(june_temp_list, december_temp_list)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09358417752050169, 'fraction_numerical': 0.001447178002894356, 'mean_word_length': 5.822368421052632, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '639918', 'license': 'MIT', 'n_tokens_mistral': 653, 'n_tokens_neox': 628, 'n_words': 193, 'path': 'temp_analysis_bonus_1.ipynb', 'repo_name': 'poonam-ux/SQLAlchemy-challenge_Climate-analysis_App', 'size': '2073'}