-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
40 lines (37 loc) · 1.32 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# import the dataset and pandas library
import pandas as pd
import distance
df = pd.read_csv("final.csv")
pd.options.mode.chained_assignment = None
class Destination (object):
def __init__(self,location):
self.loc = location
def result(self):
df["DISTANCE"] = distance.distance(self.loc)
return df
def occupied(self, lot):
count = df.index[df["ADDRESS"]==lot]
if (df['NUM_SPACES'][count]).empty :
print ("Spaces information unavailable for this parking lot")
else:
df['NUM_SPACES'][count] = df['NUM_SPACES'][count] -1
return df
def left(self, lot):
count = df.index[df["ADDRESS"]==lot]
if (df['NUM_SPACES'][count]).empty:
print ("Spaces information unavailable for this parking lot")
else:
df['NUM_SPACES'][count] = df['NUM_SPACES'][count] +1
return df
# sort the whole dataframe based on lowest (closest) distance values to biggest ones
a = Destination(input("Enter destination: "))
a.result()
df = df.sort_values(by=['DISTANCE'], kind= 'mergesort')
df = df[['NUM_SPACES', 'ADDRESS', 'LOCATION_DESCRIPTION','PARKING_COST', 'PAYMENT_METHOD', 'HOURS', 'DAYS', 'DISTANCE' ]]
print(df)
# marks the chosen spot occupied
a.occupied(input("Enter parking lot to arrive: ").upper())
print(df)
# unmark the spot
a.left(input("Enter parking lot to leave: ").upper())
print(df)