Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please help me complete these coding lines using python. 15]: from nath import radians, cos, s in, asn, sqrt def haversine(lon1, 1at1, 1on2, 1at2): nan

Please help me complete these coding lines using python. image text in transcribed
image text in transcribed
image text in transcribed
15]: from nath import radians, cos, s in, asn, sqrt def haversine(lon1, 1at1, 1on2, 1at2): nan Calculate the great circle distance between two points on the earth (specified in decinal degrees) nman * convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) - haversine formula dlon =1 on 210n1 dlat = lat2 lat1 a=sin(dlat/2)cos+cos(lat1)=cos(1at2)=sin(dion/2)(2 c=2=asin(sqrt(a)) km=6367c return bai Question 2.1.1. Use the haversine formula to determine the distance in kilometers for the first bicycle crash in the Bike. CH table and Hanes Hall. Assign this value to First_Crash Distance. Do we really need to consider the curvature of the Earth when traveling locally in Chapel Hill? Absolutely not... but we're going to do it anyways! []: First_Crash_Distance = First_Crash_Distance Question 2.1.2. Next you will determine the distance of each blcycle crash in the Bike_CH table from Hanes Hall, Begin by creating a table Bike_CH_with_Hanes that contains the same rows and columns as 8ike_CH, and adds two new columns: X Hanes and Y Hanes, These columns will have the values for the longitude of Hanes Hall ( X Hanes) and latitude of Hanes Hall ( Y Hanes) repeated for each row of the column. To do this, you can use the np.repeato function from numpy. This function takes in two arguments, first the value that you want to repeat and then how many times you want to repeat it. For instance in the cell below an array is created by repeating 020 times. [ ]: np.repeot(0, 20) [] Question 2.1.3. Next you will use the apply function to determine the distances of each bicycle crash from Hanes Hall. Create a new table BIke_CH__Dist_Fron_Hanes which contains the same columns and rows as Bike_CH_with_Hanes as well as a new column Distance Froa Hanes which contains the values in kilometers for the distance from each bioycle acdident from Hanes Hall [ ]: Bike_CH_Oist_From_Hanes _.... Bike_ololst_from_Hanes Question 2.1.3. Next you will use the apply function to determine the distances of each bicycle crash from Hanes Hall. Create a new table Bike_CH_Dist__Fron_Hanes which contains the same columns and rows as B1ke_ch_ulth_Hanes as well as a new column olstance From Hanes which contains the values in Kilometers for the distance from each bicycle accident from Hanes Hall. [] ] Bike_CH_OLst_Froa__Hanes = ... bike_ch_Olst_Froa_Henes Questlon 2.1.4 For the accidents in the Bike_CH_with_Hanes table that are within 1.5 miles of Hanes Hall, what proportion of them required an ambulance (AabulanceR, Yes / Mo )? Note that the Haversine function calculates the distance in kilometers. One mile is approximately 1.60934 kilometers. Assign this value to Prop_close_vith anbulance. []s Prop_close_yith__ albulance L... Prop_close_with_gibulance Congratulations, you're done with homework 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions