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
@@ -420,17 +422,27 @@ def to_pandas(
420422
421423 Args:
422424 max_download_size (int, default None):
425+ .. deprecated:: 2.0.0
426+ `max_download_size` parameter is deprecated. Please use `to_pandas_batch()` method
427+ instead.
428+
423429 Download size threshold in MB. If max_download_size is exceeded when downloading data
424430 (e.g., to_pandas()), the data will be downsampled if
425431 bigframes.options.sampling.enable_downsampling is True, otherwise, an error will be
426432 raised. If set to a value other than None, this will supersede the global config.
427433 sampling_method (str, default None):
434+ .. deprecated:: 2.0.0
435+ `sampling_method` parameter is deprecated. Please use `sample()` method instead.
436+
428437 Downsampling algorithms to be chosen from, the choices are: "head": This algorithm
429438 returns a portion of the data from the beginning. It is fast and requires minimal
430439 computations to perform the downsampling; "uniform": This algorithm returns uniform
431440 random samples of the data. If set to a value other than None, this will supersede
432441 the global config.
433442 random_state (int, default None):
443+ .. deprecated:: 2.0.0
444+ `random_state` parameter is deprecated. Please use `sample()` method instead.
445+
434446 The seed for the uniform downsampling algorithm. If provided, the uniform method may
435447 take longer to execute and require more computation. If set to a value other than
436448 None, this will supersede the global config.
@@ -449,6 +461,19 @@ def to_pandas(
449461 is not exceeded; otherwise, a pandas Series with downsampled rows of the DataFrame. If dry_run
450462 is set to True, a pandas Series containing dry run statistics will be returned.
451463 """
464+ if max_download_size is not None :
465+ msg = bfe .format_message (
466+ "DEPRECATED: The `max_download_size` parameters for `Series.to_pandas()` "
467+ "are deprecated and will be removed soon. Please use `Series.to_pandas_batch()`."
468+ )
469+ warnings .warn (msg , category = UserWarning )
470+ if sampling_method is not None or random_state is not None :
471+ msg = bfe .format_message (
472+ "DEPRECATED: The `sampling_method` and `random_state` parameters for "
473+ "`Series.to_pandas()` are deprecated and will be removed soon. "
474+ "Please use `Series.sample().to_pandas()` instead for sampling."
475+ )
476+ warnings .warn (msg , category = UserWarning )
452477
453478 if dry_run :
454479 dry_run_stats , dry_run_job = self ._block ._compute_dry_run (
0 commit comments