3535 Tuple ,
3636 Union ,
3737)
38+ import warnings
3839
3940import bigframes_vendored .constants as constants
4041import bigframes_vendored .pandas .core .series as vendored_pandas_series
6162import bigframes .core .window_spec as windows
6263import bigframes .dataframe
6364import bigframes .dtypes
65+ import bigframes .exceptions as bfe
6466import bigframes .formatting_helpers as formatter
6567import bigframes .operations as ops
6668import bigframes .operations .aggregations as agg_ops
@@ -432,17 +434,27 @@ def to_pandas(
432434
433435 Args:
434436 max_download_size (int, default None):
435- Download size threshold in MB. If max_download_size is exceeded when downloading data
436- (e.g., to_pandas()), the data will be downsampled if
437- bigframes.options.sampling.enable_downsampling is True, otherwise, an error will be
438- raised. If set to a value other than None, this will supersede the global config.
437+ .. deprecated:: 2.0.0
438+ ``max_download_size`` parameter is deprecated. Please use ``to_pandas_batches()``
439+ method instead.
440+
441+ Download size threshold in MB. If ``max_download_size`` is exceeded when downloading data,
442+ the data will be downsampled if ``bigframes.options.sampling.enable_downsampling`` is
443+ ``True``, otherwise, an error will be raised. If set to a value other than ``None``,
444+ this will supersede the global config.
439445 sampling_method (str, default None):
446+ .. deprecated:: 2.0.0
447+ ``sampling_method`` parameter is deprecated. Please use ``sample()`` method instead.
448+
440449 Downsampling algorithms to be chosen from, the choices are: "head": This algorithm
441450 returns a portion of the data from the beginning. It is fast and requires minimal
442451 computations to perform the downsampling; "uniform": This algorithm returns uniform
443452 random samples of the data. If set to a value other than None, this will supersede
444453 the global config.
445454 random_state (int, default None):
455+ .. deprecated:: 2.0.0
456+ ``random_state`` parameter is deprecated. Please use ``sample()`` method instead.
457+
446458 The seed for the uniform downsampling algorithm. If provided, the uniform method may
447459 take longer to execute and require more computation. If set to a value other than
448460 None, this will supersede the global config.
@@ -461,6 +473,19 @@ def to_pandas(
461473 is not exceeded; otherwise, a pandas Series with downsampled rows of the DataFrame. If dry_run
462474 is set to True, a pandas Series containing dry run statistics will be returned.
463475 """
476+ if max_download_size is not None :
477+ msg = bfe .format_message (
478+ "DEPRECATED: The `max_download_size` parameters for `Series.to_pandas()` "
479+ "are deprecated and will be removed soon. Please use `Series.to_pandas_batches()`."
480+ )
481+ warnings .warn (msg , category = FutureWarning )
482+ if sampling_method is not None or random_state is not None :
483+ msg = bfe .format_message (
484+ "DEPRECATED: The `sampling_method` and `random_state` parameters for "
485+ "`Series.to_pandas()` are deprecated and will be removed soon. "
486+ "Please use `Series.sample().to_pandas()` instead for sampling."
487+ )
488+ warnings .warn (msg , category = FutureWarning )
464489
465490 if dry_run :
466491 dry_run_stats , dry_run_job = self ._block ._compute_dry_run (
0 commit comments