twinlab.get_sample#

twinlab.get_sample(df, key)[source]#

Retrieve an individual sample from the multi-indexed dataframe returned by the Emulator.sample() method.

The output from the Emulator.sample() method is a multi-indexed dataframe where the first level of the index is the parameter name and the second level is the sample number. This convenience method allows you to isolate an individual sample from the dataframe by providing the sample number. The sample is returned as a standard dataframe.

Parameters:
  • df (pd.DataFrame) – A multi-indexed dataframe returned by the Emulator.sample() method.

  • key (int) – The integer key for the sample to retrieve.

Returns:

The individual sample as a standard (non-multi-indexed) dataframe.

Return type:

pd.DataFrame

Example

df = emulator.sample(df_X, 5) # Generates independent samples
tl.get_sample(df, 1) # Isolate sample "1"
          y
0  1.097485
1  0.835439
2  0.655124