This problem is the continuation of HW 7. In HW 7, you solved the following issues...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This problem is the continuation of HW 7. In HW 7, you solved the following issues in the dataset 1. Some values in the the FlightNumber column are missing. These numbers are meant to increase by 10 with each row so 10055 and 10075 need to be put in place. Fill in these missing numbers and make the column an integer column (instead of a float column). 2. The From_To column would be better as two separate columns! Split each string on the underscore delimiter to give a new temporary DataFrame with the correct values. Assign the correct column names to this temporary DataFrame. 3. Notice how the capitalisation of the city names is all mixed up in this temporary DataFrame. Standardise the strings so that only the first letter is uppercase (e.g. "londON" should become "London".) 4. Delete the From_To column from df and attach the temporary DataFrame from the previous questions. In this homework, you are going to solve the following issue, 5. In the RecentDelays column, the values have been entered into the DataFrame as a list. We would like each first value in its own column, each second value in its own column, and so on. If there isn't an Nth value, the value should be NaN. Expand the Series of lists into a DataFrame named delays, rename the columns delay_1, delay_2, etc. and replace the unwanted RecentDelays column in df with delays. In [1] import numpy as np import pandas as pd In [2]: df = pd.DataFrame({ 'From_To': ['LONDon_paris', 'MAdrid_miLAN', 'londON_Stockholm', 'Budapest PaRis', 'Brussels_london'], 'FlightNumber': [10045, np.nan, 10065, np.nan, 10085], 'RecentDelays': [[23, 47], [], [24, 43, 87], [13], [67, 32]], 'Airline': ['KLM (!)', '<Air France> (12)', '(British Airways. )', '12. Air France', '"Swiss Air"]}) This problem is the continuation of HW 7. In HW 7, you solved the following issues in the dataset 1. Some values in the the FlightNumber column are missing. These numbers are meant to increase by 10 with each row so 10055 and 10075 need to be put in place. Fill in these missing numbers and make the column an integer column (instead of a float column). 2. The From_To column would be better as two separate columns! Split each string on the underscore delimiter to give a new temporary DataFrame with the correct values. Assign the correct column names to this temporary DataFrame. 3. Notice how the capitalisation of the city names is all mixed up in this temporary DataFrame. Standardise the strings so that only the first letter is uppercase (e.g. "londON" should become "London".) 4. Delete the From_To column from df and attach the temporary DataFrame from the previous questions. In this homework, you are going to solve the following issue, 5. In the RecentDelays column, the values have been entered into the DataFrame as a list. We would like each first value in its own column, each second value in its own column, and so on. If there isn't an Nth value, the value should be NaN. Expand the Series of lists into a DataFrame named delays, rename the columns delay_1, delay_2, etc. and replace the unwanted RecentDelays column in df with delays. In [1] import numpy as np import pandas as pd In [2]: df = pd.DataFrame({ 'From_To': ['LONDon_paris', 'MAdrid_miLAN', 'londON_Stockholm', 'Budapest PaRis', 'Brussels_london'], 'FlightNumber': [10045, np.nan, 10065, np.nan, 10085], 'RecentDelays': [[23, 47], [], [24, 43, 87], [13], [67, 32]], 'Airline': ['KLM (!)', '<Air France> (12)', '(British Airways. )', '12. Air France', '"Swiss Air"]})
Expert Answer:
Answer rating: 100% (QA)
Answer Alright lets proceed stepbystep as per your requirements Task 1 First we want to separate the ... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Create the DataFrame to use in the following data: df = pd.DataFrame({'From_To': ['LoNDon_paris', 'MAdrid_miLAN', 'londON_StockhOlm', 'Budapest_PaRis', 'Brussels_londOn'], 'FlightNumber': [10045,...
-
What functions are there in the mazeAsn4 module: print_maze(maze) Description: This function displays the maze. The accessible cells are labelled G i.e. green, the blocked cells are labelled R i.e....
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Prove that if a planetary orbit is circular of radius R, then vT = 2R, where v is the planets speed (constant by Exercise 7) and T is the period. Then use Keplers Third Law to prove that Data From...
-
Presented below is an aging schedule for Gille Company At December 31, 2011, the unadjusted balance in Allowance for Doubtful Accounts is a credit of $8,000.Instructions(a) Journalize and post the...
-
If the radius of convergence of the power series is 10, what is the radius of convergence of the series ? way?
-
Let \(X_{t}=b t+W_{t}+Z_{t}\) where \(W\) is a Brownian motion and \(Z_{t}=\sum_{k=1}^{N_{t}} Y_{k}\) a \((\lambda, F)\)-compound Poisson process independent of \(W\). The first passage time above...
-
Beth R. Jordan lives at 2322 Skyview Road, Mesa, AZ 85201. She is a tax accountant with Mesa Manufacturing Company, 1203 Western Avenue, Mesa, AZ 85201 (employer identification number 11-1111111)....
-
(6 points) Let A Cnxn. Show that A is normal iff a unitary U Cnn and diagonal D Cn such that D = U*AU, namely, A = UDU*.
-
You are mapping metamorphic rocks and you notice a lineation within the rocks. At five different outcrops you measure the pitch of the lineation on an exposed planar rock surface (not necessarily the...
-
A golf ball having mass of 0.05 kg rests on a tee. The ball is then struck with a club having a mass of 0.3 kg. The ball acquires a velocity of 30 m/s. The impulse imparted to the ball by the club is...
-
Endosomal vesicles are not able to deliver content to lysosomes. The vesicles are expressing v-snare proteins and the lysosomes are expressing t-snare proteins. What could explain this issue? I 19....
-
Find the correct answer for the following binary multiplication (Show details of your work): 1) (10110) 2 (1110)2= )2 * 2) (101101) 2 (111101)2= ( )2
-
(a) (b) (c) Calculate the resolution required to resolve peaks for = 410 nm and 2 which has a wavenumber of 24100 cm-1 (3 marks) ICP-OES and AA can be complimentary techniques. Discuss this...
-
Prost paid legal fees for the transfer of assets and liabilities of $17,000. Prost also paid audit fees of $27,000 and listing application fees of $16,000, both related to the issuance of new shares....
-
Describe the teacher clinician(s) you interviewed (no names, please), what they do, where they work, how long they've been a practicing professional. How long (minutes) did it take you to conduct...
-
The national distribution of fatal work injuries in a country is shown in the table to the right under National %. You believe that the distribution of fatal work injuries is different in the western...
-
1. Firms may hold financial assets to earn returns. How the firm would classify financial assets? What treatment will such financial assets get in the financial statements in accordance with US GAAP...
-
Matthew borrows $250,000 to invest in bonds. During 2012, his interest on the loan is $30,000. Matthew's interest income from the bonds is $10,000. This is Matthew's only investment income. a....
-
During 2012, Tom sold Sears stock for $10,000. The stock was purchased 4 years ago for $13,000. Tom also sold Ford Motor Company bonds for $35,000. The bonds were purchased 2 months ago for $30,000....
-
Larry and Lisa Williams, both 33 years old, have been married for 9 years. They live at 638 Arctic Way, Fairbanks, AK 99701. Lisa's Social Security number is 445- 81-1423 and Larry's is 798-09-8526....
-
A 2.0-cm-tall object is \(15 \mathrm{~cm}\) in front of a diverging lens that has a \(-20 \mathrm{~cm}\) focal length. Calculate the image position and height.
-
A \(1.0-\mathrm{cm}\)-tall object is \(60 \mathrm{~cm}\) in front of a diverging lens that has a \(-30 \mathrm{~cm}\) focal length. Calculate the image position and height.
-
A 3.0-cm-tall object is \(15 \mathrm{~cm}\) in front of a convex mirror that has a \(-25 \mathrm{~cm}\) focal length. Calculate the image position and height.
Study smarter with the SolutionInn App