File size: 1,220 Bytes
9be4956 |
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 |
# import os
# from tools.flights.apis import Flights
# import re
# import sys
# import os
# flight = Flights('/home/xj/toolAugEnv/code/toolConstraint/database/flights/clean_Flights_2022.csv')
# data = flight.run('Austin', 'Seattle', '2022-03-01')
# # print(len(data))
# print(data)
from tools.flights.apis import Flights
import pandas as pd
import sys
import os
# results = self.data[self.data["OriginCityName"] == origin]
# results = results[results["DestCityName"] == destination]
sys.path.append(os.path.abspath(os.path.join(os.getcwd(), "..")))
os.chdir(os.path.dirname(os.path.abspath(__file__)))
unique_cities = list(Flights(path="../../database/flights/clean_Flights_2022.csv").data['OriginCityName'].unique()) + list(Flights(path="../../database/flights/clean_Flights_2022.csv").data['DestCityName'].unique())
df = Flights(path="../../database/flights/clean_Flights_2022.csv").data
print(len(df))
citySet = open('../../database/background/citySet.txt','r').read().split('\n')
cnt = 0
for city in unique_cities:
if city not in citySet:
df = df[(df['OriginCityName'] != city) & (df['DestCityName'] != city)]
print(len(df))
df.to_csv('../../database/flights/clean_Flights_2022.csv', index=False) |