2424import textwrap
2525import typing
2626from typing import Any , cast , List , Literal , Mapping , Optional , Sequence , Tuple , Union
27+ import warnings
2728
2829import bigframes_vendored .constants as constants
2930import bigframes_vendored .pandas .core .series as vendored_pandas_series
4950import bigframes .core .window_spec as windows
5051import bigframes .dataframe
5152import bigframes .dtypes
53+ import bigframes .exceptions as bfe
5254import bigframes .formatting_helpers as formatter
5355import bigframes .operations as ops
5456import bigframes .operations .aggregations as agg_ops
@@ -387,17 +389,27 @@ def to_pandas(
387389
388390 Args:
389391 max_download_size (int, default None):
392+ .. deprecated:: 2.0.0
393+ `max_download_size` parameter is deprecated. Please use `to_pandas_batch()` method
394+ instead.
395+
390396 Download size threshold in MB. If max_download_size is exceeded when downloading data
391397 (e.g., to_pandas()), the data will be downsampled if
392398 bigframes.options.sampling.enable_downsampling is True, otherwise, an error will be
393399 raised. If set to a value other than None, this will supersede the global config.
394400 sampling_method (str, default None):
401+ .. deprecated:: 2.0.0
402+ `sampling_method` parameter is deprecated. Please use `sample()` method instead.
403+
395404 Downsampling algorithms to be chosen from, the choices are: "head": This algorithm
396405 returns a portion of the data from the beginning. It is fast and requires minimal
397406 computations to perform the downsampling; "uniform": This algorithm returns uniform
398407 random samples of the data. If set to a value other than None, this will supersede
399408 the global config.
400409 random_state (int, default None):
410+ .. deprecated:: 2.0.0
411+ `random_state` parameter is deprecated. Please use `sample()` method instead.
412+
401413 The seed for the uniform downsampling algorithm. If provided, the uniform method may
402414 take longer to execute and require more computation. If set to a value other than
403415 None, this will supersede the global config.
@@ -416,6 +428,19 @@ def to_pandas(
416428 is not exceeded; otherwise, a pandas Series with downsampled rows of the DataFrame. If dry_run
417429 is set to True, a pandas Series containing dry run statistics will be returned.
418430 """
431+ if max_download_size is not None :
432+ msg = bfe .format_message (
433+ "DEPRECATED: The `max_download_size` parameters for `Series.to_pandas()` "
434+ "are deprecated and will be removed soon. Please use `Series.to_pandas_batch()`."
435+ )
436+ warnings .warn (msg , category = UserWarning )
437+ if sampling_method is not None or random_state is not None :
438+ msg = bfe .format_message (
439+ "DEPRECATED: The `sampling_method` and `random_state` parameters for "
440+ "`Series.to_pandas()` are deprecated and will be removed soon. "
441+ "Please use `Series.sample().to_pandas()` instead for sampling."
442+ )
443+ warnings .warn (msg , category = UserWarning )
419444
420445 if dry_run :
421446 dry_run_stats , dry_run_job = self ._block ._compute_dry_run (
0 commit comments