Question 1.1 It looks like the departure and arrival in flights were read in as floating-point numbers. Write two functions, extract_hour and extract_mins that converts military time to hours and minutes, respectively. Hint: You may want to use modular arithmetic and integer division. Keep in mind that the data has not been cleaned and you need to check whether the extracted values are valid. Replace all the invalid values with NaN . The documentation for pandas.Series.where provided here should be helpful. In [ ]: def extract_hour(time): H Extracts hour information from military time. Args: time (float64): series of time given in military format. Takes on values in 0.0-2359.0 due to float64 representation. Returns: array (float64): series of input dimension with hour information. Should only take on integer values in 0-23 *** # [YOUR CODE HERE] # You MUST add comments explaining your thought process, # and the resources you used to solve this question (if any) hour return hour 'blabla' # test your code test_ser = pd.Series ([1030.0, 1259.0, np.nan, 2400], dtype='float64') extract_hour(test_ser) 10.0 12.0 NaN NaN # 0 # 1 # 2 # 3 #dtype: float64

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

airports.dat and airlines.dat, respectively. Both were sourced from http://openflights.org/data.html.

In [ ]: def extract_mins(time):
Extracts minute information from military time
Args:
time (float64): series of time given in military format.
Takes on values in 0.0-2359.0 due to float64 representation.
Returns:
array (float64): series of input dimension with minute information.
Should only take on integer values in 0-59
|||||
# [YOUR CODE HERE]
# You MUST add comments explaining your thought process,
# and the resources you used to solve this question (if any)
mins='blabla'
return mins
# test your code
test_ser = pd.Series ([1030.0, 1259.0, np.nan, 2475], dtype='float64')
extract_mins (test_ser)
# 0
# 1
# 2
# 3
#dtype: float64
30.0
59.0
NaN
NaN
Transcribed Image Text:In [ ]: def extract_mins(time): Extracts minute information from military time Args: time (float64): series of time given in military format. Takes on values in 0.0-2359.0 due to float64 representation. Returns: array (float64): series of input dimension with minute information. Should only take on integer values in 0-59 ||||| # [YOUR CODE HERE] # You MUST add comments explaining your thought process, # and the resources you used to solve this question (if any) mins='blabla' return mins # test your code test_ser = pd.Series ([1030.0, 1259.0, np.nan, 2475], dtype='float64') extract_mins (test_ser) # 0 # 1 # 2 # 3 #dtype: float64 30.0 59.0 NaN NaN
Question 1.1
It looks like the departure and arrival in flights were read in as floating-point numbers. Write two functions, extract_hour and extract_mins that
converts military time to hours and minutes, respectively. Hint: You may want to use modular arithmetic and integer division. Keep in mind that the data has not
been cleaned and you need to check whether the extracted values are valid. Replace all the invalid values with NaN. The documentation for
pandas.Series. where provided here should be helpful.
In [ ]: def extract_hour(time):
Extracts hour information from military time.
Args:
time (float64): series of time given in military format.
Takes on values in 0.0-2359.0 due to float64 representation.
Returns:
array (float64): series of input dimension with hour information.
Should only take on integer values in 0-23
# [YOUR CODE HERE]
# You MUST add comments explaining your thought process,
# and the resources you used to solve this question (if any)
hour 'blabla'
return hour
=
# test your code
test_ser = pd.Series ([1030.0, 1259.0, np.nan, 2400], dtype='float64')
extract_hour(test_ser)
10.0
12.0
NaN
NaN
# 0
# 1
# 2
# 3
#dtype: float64
Transcribed Image Text:Question 1.1 It looks like the departure and arrival in flights were read in as floating-point numbers. Write two functions, extract_hour and extract_mins that converts military time to hours and minutes, respectively. Hint: You may want to use modular arithmetic and integer division. Keep in mind that the data has not been cleaned and you need to check whether the extracted values are valid. Replace all the invalid values with NaN. The documentation for pandas.Series. where provided here should be helpful. In [ ]: def extract_hour(time): Extracts hour information from military time. Args: time (float64): series of time given in military format. Takes on values in 0.0-2359.0 due to float64 representation. Returns: array (float64): series of input dimension with hour information. Should only take on integer values in 0-23 # [YOUR CODE HERE] # You MUST add comments explaining your thought process, # and the resources you used to solve this question (if any) hour 'blabla' return hour = # test your code test_ser = pd.Series ([1030.0, 1259.0, np.nan, 2400], dtype='float64') extract_hour(test_ser) 10.0 12.0 NaN NaN # 0 # 1 # 2 # 3 #dtype: float64
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education