Question: I'm more interested in understanding how to use the function and how to pass a pd.dataframe to it. I don't understand the arrow arguments or
I'm more interested in understanding how to use the function and how to pass a pd.dataframe to it. I don't understand the arrow arguments or how they're able to use "dataset: " and "target_col:". I'm used to functions looking more like this: def func(data, col):. What does "-> tuple [..]" mean?
The actual data that is supposed to be passed to the function is a csv with a few thousand rows and a 20+ columns.
import numpy as np import pandas as pd
def find_dataset_statistics(dataset:pd.DataFrame,target_col:str) -> tuple[int,int,int,int,float]: # TODO: Write the necessary code to generate the following dataset statistics given a dataframe # and a target column name.
#Total number of records n_records = 0 #Total number of columns n_columns = 0 #Number of records where target is negative n_negative = 0 #Number of records where where target is positive n_positive = 0 # Percentage of instances of positive target value perc_positive = 0
return n_records,n_columns,n_negative,n_positive,perc_positive
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
