Question: Please write Python code in an original and efficient manner. It should be both original and capable of working efficiently. import numpy import pandas class

Please write Python code in an original and efficient manner. It should be both original and capable of working efficiently.
import numpy
import pandas
class InputError(Exception):
pass
def fill_spaces(data: numpy.array, editing_mode: int)-> numpy.array:
""" This function will take a numpy.array of size (m,) where m >0 as input.
It is known that the valid numbers within this array are between 0 and 100.
It will fill all values that do not comply with the specified range;
with the previous valid value if editing_mode is 0,
with the average value of the previous and next valid values if editing_mode is 1,
with the average value of the remaining values if editing_mode is 2.
If all data values are outside the desired range, False will be returned.
Args:
data: numpy.array
Returns:
result: numpy.array or bool (False)
Example:
data: numpy.array([1,2,3,4,5,6,-1,8,9,10,11])
editing_mode: 0
result: numpy.array([1,2,3,4,5,6,6,8,9,10,11])
editing_mode: 1
result: numpy.array([1,2,3,4,5,6,7,8,9,10,11])
editing_mode: 2
result: numpy.array([1,2,3,4,5,6,5.9,8,9,10,11])
"""
return NotImplementedError
def remove_duplicates(df: panclass InputError(Exception):
pass
def fill_spaces(data: numpy.array, editing_mode: int)-> numpy.array:
""" This function will take a numpy.array of size ,) where m>0 as input
It is known that the valid numbers within this array are between 0 and
It will fill all values that do not comply with the specified range;
with the previous valid value if editing_mode is 0,
with the average value of the previous and next valid values if editing
with the average value of the remaining vadas.DataFrame)-> pandas.DataFrame:
""" This function removes rows of duplicate timestamps in a DataFrame with timestamps in its first column
(column name is not known) and keeps only the row of the most recent/newest timestamp in the DataFrame.
The input DataFrame remains unchanged when this function is executed.
Args:
df: DataFrame (pandas.DataFrame)
Returns:
result: DataFrame (pandas.DataFrame)
Example:
Shown in the visual.
"""
return NotImplementedError
def days_until_end_of_year(input_date: str)-> int:
""" This function returns the number of days left until the end of the year when a date in the format of "YYYY-MM-DD" is received.
The current day is not counted.
Args:
input_date: str
Returns:
result: int
Example:
input_date ="2022-12-29"
result =2
"""
return NotImplementedError
def my_max_pooling(matrix: numpy.array)-> numpy.array:
""" When a square matrix of size (N, N) with N being an even number is received as input,
this function creates a new square matrix of size (N/2, N/2) using the maximum number
in each (2,2) non-overlapping area.
Args:
matrix (numpy.array): Input array of size (N,N). N is a multiple of 4.
Returns:
result: numpy.array
Example:
Shown in the visual.
"""
return NotImplementedError
def find_problematic_boroughs(df: pandas.DataFrame)-> list:
""" This function returns the names of the top 5 boroughs with the highest number of illegal parking complaints
(Illegal Parking / Complaints) and their complaint counts as tuples from the DataFrame
"311-service-requests.csv" read with the file_read function.
Args:
df: Dataframe (pandas.DataFrame)
Returns:
result: list of tuples
Example:
[("BROOKLYN",1147),..]
"""
return NotImplementedError
def unique_agency_count(df: pandas.DataFrame)-> int:
""" This function returns the count of unique agency names in the DataFrame
"311-service-requests.csv" read with the file_read function.
Args:
df: Dataframe (pandas.DataFrame)
Returns:
result: int
"""
return NotImplementedError
def most_common_complaint_types(df: pandas.DataFrame, N: int)-> list:
""" This function returns a string list of the top N most common complaint types
from the DataFrame "311-service-requests.csv" read with the file_read function.
N can be between 1 and 165.
Args:
df: DataFrame to process (pandas.DataFrame)
N: Number of Repetitions (int)
Returns:
result: list
"""
return NotImplementedError
def file_read(file_path: str)-> pandas.DataFrame:
""" This function reads .csv or .tab files and returns the output as a Pandas DataFrame.
It is certain that the first row of these files will contain attribute names.
Args:
file_path (str): File path to be read with .csv or .tab extension
Returns:
result: pandas.DataFrame
"""
return NotImplementedError
Please write Python code in an original and

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!