Question: based on the python code: import pandas as pd import re # Load the data flights = pd.read_csv('data-sets/flights.csv') planes = pd.read_csv('data-sets/planes.csv') airlines = pd.read_csv('data-sets/airlines.csv') airports

based on the python code:

import pandas as pd import re # Load the data flights = pd.read_csv('data-sets/flights.csv') planes = pd.read_csv('data-sets/planes.csv') airlines = pd.read_csv('data-sets/airlines.csv') airports = pd.read_csv('data-sets/airports.csv') # Step 1: Merge planes and flights data on 'tailnum' planes_subset = planes[['tailnum', 'model', 'manufacturer']] flights2 = flights.merge(planes_subset, on='tailnum', how='inner') # Step 2: Merge airlines data into flights data on 'carrier' flights3 = flights2.merge(airlines, left_on='carrier', right_on='carrier', how='left') # Step 3: Merge airports data into flights data on 'dest' airports_subset = airports[['faa', 'latitude', 'longitude']] flights_final = flights3.merge(airports_subset, left_on='dest', right_on='faa', how='left')

find:

a)We can see in the data set that only some of the planes have tail numbers that end in two letters. We would like to generate a dictionary that contains the last two letters in a tail number, for each of the different carriers in the data set.

b)Determine how many flights went to each of the destinations from New York in January of 2013. Store this in a data frame called flightCount.

Hint: the to_frame() function may be helpful. Then generate a new data frame called temp that merges the flights_final data with flightCount. The code that is provided will then plot the flight data on the map of the US.

  1. Provide a brief description of what the code that has been provided to you is doing.
  2. Provide at least 1 insight into what this graph tells us about flights from new York

fig, ax = plt.subplots(figsize=(8,6))

earthPath = geopandas.datasets.get_path("naturalearth_lowres")

world = geopandas.read_file(earthPath)

usa = world.loc[world['name'] == 'United States of America']

usa.plot(color = 'white', edgecolor = 'black', ax = ax)

size = temp['dest_y']/temp['dest_y'].max()*100

flights_final.plot(x = 'lon', y = 'lat', kind = 'scatter', s = size, ax = ax)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!