text_html_output_1.png
from google.colab import drive

import h3

import pandas as pd

kaggle = False
try:
    from google.colab import drive
    drive.mount('/content/drive')
except ModuleNotFoundError:
    path = '../input/google-bike-share/clean_df.csv'
    kaggle = True
else:
    path = '/content/drive/MyDrive/Colab Notebooks/Google Capstone Project/data/clean_data/240/clean_df.csv'
finally:
    df = pd.read_csv(path)

df = df.query('start_lat < 42.2')

df['distance'] = df.apply(lambda row: h3.point_dist((row['start_lat'], row['start_lng']), (row['end_lat'], row['end_lng']), unit='km'), axis=1)

df = df.drop(['start_lat', 'start_lng', 'end_lat', 'end_lng'], axis=1)

df.query('distance > 20')[['distance', 'ride_length', 'start_station', 'end_station']].sort_values(by=['distance'], ascending=False).head(5)

df = df.query('distance < 43')

df = df.drop(['ride_id', 'started_at', 'ended_at', 'day_of_week', 'month', 'ride_length'], axis=1)

months = [df.query(f'int_month == {i}') for i in range(1, 13)]

sample_df = df.sample(n=6758)

sample_df = sample_df.sort_values(by=['date', 'time_start'])

sample_df.describe().T