Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This problem is the continuation of HW 7. In HW 7, you solved the following issues in the dataset 1. Some values in the

     

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 (!)', ' (12)', '(British Airways. )', '12. Air France', '"Swiss Air"]})

Step by Step Solution

3.53 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

Answer Alright lets proceed stepbystep as per your requirements Task 1 First we want to separate the ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions