# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

import numpy as np
import pandas as pd
import os
import glob
import ntpath
from decimal import Decimal


def Lat_Long_Boundries(datasets_address):
    
    boundries ={'min_lat':40.5,'max_lat':40.9,'min_lng':-74.1,'max_lng':-73.7}
    
    path = os.getcwd()
    csv_files = glob.glob(os.path.join(datasets_address, "*.csv"))

    for i in csv_files:
        
        data = pd.read_csv(i)
        if 'start station latitude' in data.columns:
            data = data.loc[((boundries['min_lat'] <= data.loc[:,'start station latitude'])  & (data.loc[:,'start station latitude']  <= boundries['max_lat'])) & 
                            ((boundries['min_lat'] <= data.loc[:,'end station latitude'])    & (data.loc[:,'end station latitude']    <= boundries['max_lat'])) &
                            ((boundries['min_lng'] <= data.loc[:,'start station longitude']) & (data.loc[:,'start station longitude'] <= boundries['max_lng'])) &
                            ((boundries['min_lng'] <= data.loc[:,'end station longitude'])   & (data.loc[:,'end station longitude']   <= boundries['max_lng']))]
        elif 'start_lat' in data.columns:
            data = data.loc[((boundries['min_lat'] <= data.loc[:,'start_lat']) & (data.loc[:,'start_lat'] <= boundries['max_lat'])) & 
                            ((boundries['min_lat'] <= data.loc[:,'end_lat'])   & (data.loc[:,'end_lat']   <= boundries['max_lat'])) &
                            ((boundries['min_lng'] <= data.loc[:,'start_lng']) & (data.loc[:,'start_lng'] <= boundries['max_lng'])) &
                            ((boundries['min_lng'] <= data.loc[:,'end_lng'])   & (data.loc[:,'end_lng']   <= boundries['max_lng']))]            

        data.to_csv(i, index = False)


Lat_Long_Boundries("C:/Users/adria/OneDrive/Desktop")

df = pd.read_csv("C:/Users/adria/OneDrive/Desktop/201604-citibike-tripdata.csv")

df.shape

df[df.loc[:,'start station latitude']==0]



StarcoderdataJupyterScriptsDedupFiltered