Question: Q 9 - split _ dataset ( 1 pt ) Earlier, we defined a function select _ sample ( ) which allowed us to randomly
Q splitdataset pt
Earlier, we defined a function selectsample 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 splitdataset, which will return a list of dataframes. Each dataframe in the list will be a random subsets without replacement of the input dataset.
Inputs:
dataset : DataFrame
nsplit : int, default:
Outputs:
result : list of DataFrames
Procedures:
Use samplefrom pandas, same as was used in Q with the input parameters frac and replace False. Store this in shuffled.
Use nparraysplit with shuffled and nsplit 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
