67.9k views
1 vote
To know the accuracy of our statistical estimate, we need to perform bootstrapping (i.e., resampling). Write a function named simulate_resample. It should generate a resample from the observed serial numbers located in the column serial number of the dataframe obs and return that resample. You must make sure that the resample should be a dataframe like obs. Also, the function should take no arguments. Note: Inside the function, once you resample the serial numbers, it will be useful to first create a dictionary anmed resample_dict that consists of the resampled serial numbers in a key named serial number. Use that dictionary to create a dataframe named resample_df consisting of the resampled serial numbers in a column named serial number.

User Jovicbg
by
7.5k points

1 Answer

7 votes

Final answer:

To generate a resample from the observed serial numbers located in the column 'serial number' of a dataframe and return that resample as a dataframe, you can create a function named 'simulate_resample'.

Step-by-step explanation:

To generate a resample from the observed serial numbers located in the column 'serial number' of the dataframe 'obs' and return that resample as a dataframe, you can create a function named 'simulate_resample'. This function should take no arguments. Inside the function, you can create a dictionary named 'resample_dict' that consists of the resampled serial numbers in a key named 'serial number'. Then, you can use this dictionary to create a dataframe named 'resample_df' consisting of the resampled serial numbers in a column named 'serial number'.

Here is an example implementation of the function:

import pandas as pd

def simulate_resample():
resample_dict = {
'serial number': obs['serial number'].sample(n=len(obs), replace=True).tolist()
}
resample_df = pd.DataFrame(resample_dict)
return resample_df

User Brendon Crawford
by
7.4k points