Question: Q 9 - split _ dataset ( 1 pt ) Earlier, we defined a function select _ sample ( ) which allowed us to randomly

Q9- split_dataset (1 pt)
Earlier, we defined a function select_sample() which allowed us to randomly sample a subset from our larger dataset.
Now, rather than specifying how many samples we want to randomly choose from a dataframe, let's take our entire dataframe and split it into thirds. We'll consider each third a different replicate of our experiment.
Write a function called split_dataset, which will return a list of dataframes. Each dataframe in the list will be a random subsets (without replacement) of the input dataset.
Input(s):
dataset : DataFrame
n_split : int, default: 3
Output(s):
result : list of DataFrame(s)
Procedure(s):
Use sample()(from pandas, same as was used in Q7) with the input parameters frac =1 and replace = False. Store this in shuffled.
Use np.array_split with shuffled and n_split as its input parameters. Store this in result.
return result, which stores a list of dataframes

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!