Hubway Capstone Project-- Database Connection Test¶
Hubway is a bike-share program collectively owned by the metro Boston cities; Boston, Cambridge, Somerville, and Brookline. It is operated by Motivate, who manages similar initiatives in NYC, Portland, Chicago, Washington DC, and several other metro areas in Ohio, Tennessee, and New Jersey. They are opening up operations in San Francisco during the month of June, 2017. Hubway currently exists as a system of 188 stations with 1,800 bikes.- For this project, I investigated shared data for the months of January, May, June, July, and October during the years of 2015 and 2016.
- Of concern were the questions of;
- How do riders use the bike-share service?
- Are the bikes used as a conveyance or for recreation?
- What type of customer uses the service?
- How do riders use the bike-share service?
Library import¶
In [12]:
import numpy as np
#import scipy.stats as stats
#import seaborn as sns
#import matplotlib.pyplot as plt
import pandas as pd
import sqlite3
Connection to Database¶
In [13]:
import sqlite3
hubway_db = './database/hubway_full.db'
conn = sqlite3.connect(hubway_db)
c = conn.cursor()
Verification of table in a DataFrame¶
In [14]:
hubway_df = pd.read_sql('SELECT * FROM hubway_db LIMIT 10', con=conn)
hubway_df
Out[14]:
The script connected to database locally and returned results quickly¶
In [15]:
sql_query = """
PRAGMA table_info(hubway_db)
"""
pd.read_sql(sql_query, con=conn)
Out[15]:
In [18]:
conn.close()
In [ ]:
No comments:
Post a Comment