bigframes._config.SamplingOptions#
- class bigframes._config.SamplingOptions(max_download_size: int | None = 500, enable_downsampling: bool = False, sampling_method: Literal['head', 'uniform'] = 'uniform', random_state: int | None = None)[source]#
Encapsulates the configuration for data sampling.
- enable_downsampling: bool = False#
Whether to enable downsampling. Default False.
If max_download_size is exceeded when downloading data (e.g., to_pandas()), the data will be downsampled if enable_downsampling is True, otherwise, an error will be raised.
Examples:
>>> import bigframes.pandas as bpd >>> bpd.options.sampling.enable_downsampling = True
- max_download_size: int | None = 500#
Download size threshold in MB. Default 500.
If value set to None, the download size won’t be checked.
Examples:
>>> import bigframes.pandas as bpd >>> bpd.options.sampling.max_download_size = 1000
- random_state: int | None = None#
The seed for the uniform downsampling algorithm. Default None.
If provided, the uniform method may take longer to execute and require more computation.
Examples:
>>> import bigframes.pandas as bpd >>> bpd.options.sampling.random_state = 42
- sampling_method: Literal['head', 'uniform'] = 'uniform'#
Downsampling algorithms to be chosen from. Default “uniform”.
The choices are: “head”: This algorithm returns a portion of the data from the beginning. It is fast and requires minimal computations to perform the downsampling.; “uniform”: This algorithm returns uniform random samples of the data.
Examples:
>>> import bigframes.pandas as bpd >>> bpd.options.sampling.sampling_method = "head"
- with_disabled() SamplingOptions[source]#
Configures whether to disable downsampling
- Returns:
The configuration for data sampling.
- Return type:
- with_max_download_size(max_rows: int | None) SamplingOptions[source]#
Configures the maximum download size for data sampling in MB
- Parameters:
max_rows (None or int) – An int value for the maximum row size.
- Returns:
The configuration for data sampling.
- Return type:
- with_method(method: Literal['head', 'uniform']) SamplingOptions[source]#
Configures the downsampling algorithms to be chosen from
- Parameters:
method (None or Literal) – A literal string value of either head or uniform data sampling method.
- Returns:
The configuration for data sampling.
- Return type: