INNER CODE UNIT · Python

main

tuangauss/DataScienceProjects · Python/flights_networkx.py:9

def main():
	# download airport info data
	airport_col = ['ID', 'Name', 'City', 'Country','IATA', 'ICAO', 'Lat', 'Long', 'Alt', 
	               'Timezone', 'DST', 'Tz database time zone', 'type', 'source']
	airport_df = pd.read_csv("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat",
	                        names = airport_col, index_col = 0)

	# download flight routes data
	route_cols = ['Airline', 'Airline ID', 'Source Airport', 'Source Airport ID',
	              'Dest Airport', 'Dest Airport ID', 'Codeshare', 'Stops', 'equipment']
	routes_df = pd.read_csv("https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat",
	                        names = route_cols)
	#clean up data, change 'object' type to numeric and drops NaNs
	routes_df['Source Airport ID'] = pd.to_numeric(routes_df['Source Airport ID'].astype(str), 'coerce')
	routes_df['Dest Airport ID'] = pd.to_numeric(routes_df['Dest Airport ID'].astype(str), 'coerce')
	routes_df = routes_df.dropna(subset=["Source Airport ID", "Dest Airport ID"]) 

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…