def startend(start=None, end=None):
    only_tobs = (session.query(Measurement.tobs).filter(
        Measurement.date.between(start, end)).all())

    temp_obs_df = pd.DataFrame(only_tobs)

    tavg = temp_obs_df["tobs"].mean()
    tmin = temp_obs_df["tobs"].min()
    tmax = temp_obs_df["tobs"].max()

    return jsonify(tavg, tmin, tmax)
def precipitation():
    # Create our session (link) from Python to the DB
    my_max_date = dt.date(2017, 8, 23)
    one_year_ago = my_max_date - dt.timedelta(days=365)

    lastyear = (session.query(
        Measurement.tobs).filter(Measurement.station == 'USC00519281').filter(
            Measurement.date <= my_max_date).filter(
                Measurement.date <= one_year_ago).order_by(
                    Measurement.tobs).all())

    return jsonify(lastyear)
def precipitation():
    # Create our session (link) from Python to the DB
    my_max_date = dt.date(2017, 8, 23)
    one_year_ago = my_max_date - dt.timedelta(days=365)

    past_temp = (session.query(
        Measurement.date,
        Measurement.prcp).filter(Measurement.date <= my_max_date).filter(
            Measurement.date >= one_year_ago).order_by(Measurement.date).all())

    precipitation = {date: precip for date, precip in past_temp}

    return jsonify(precipitation)
def stations():

    all_stations = session.query(Station.station).all()

    return jsonify(all_stations)
Beispiel #5
0
def tobs():
    tobs= 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()

    return jsonify(tobs)
Beispiel #6
0
def stations():
    station_query= session.query(func.count(Measurement.station)).group_by(Measurement.station).order_by(func.count(Measurement.station).desc()).all()
    return jsonify(station_query)
Beispiel #7
0
def precipitation():
    prev_year=dt.date.today()-dt.timedelta(days=700)
    result= session.query(Measurement.date, Measurement.prcp).filter(Measurement.date>=prev_year).all()
    return jsonify(result)