Skip to content

Commit 419f28a

Browse files
committed
docs(bigframes): Add docs to the to_csv methods of dataframe and series
1 parent 86a0525 commit 419f28a

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,49 @@ def to_parquet(
552552
``None``, ``snappy``, or ``gzip``.
553553
"""
554554
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
555+
556+
def to_csv(
557+
self,
558+
path_or_buf=None,
559+
sep=",",
560+
*,
561+
header: bool = True,
562+
index: bool = True,
563+
allow_large_results: Optional[bool] = None,
564+
) -> dict | list[dict]:
565+
"""
566+
Write object to a comma-separated values (csv) file.
567+
568+
**Examples:**
569+
570+
>>> import bigframes.pandas as bpd
571+
572+
>>> df = bpd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})
573+
>>> df.to_csv()
574+
\',col1,col2\\n0,1,3\\n1,2,4\\n\'
575+
576+
Args:
577+
path_or_buf (str, path object, file-like object, or None, default None):
578+
String, path object (implementing os.PathLike[str]), or file-like object
579+
implementing a write() function. If None, the result is returned as a string.
580+
If a non-binary file object is passed, it should be opened with newline='',
581+
disabling universal newlines. If a binary file object is passed,
582+
mode might need to contain a 'b'.
583+
Must contain a wildcard character '*' if this is a GCS path.
584+
sep (str, default ','):
585+
String of length 1. Field delimiter for the output file.
586+
header (bool, default True):
587+
Write out the column names.
588+
index (bool, default True):
589+
Write row names (index).
590+
allow_large_results (bool, default None):
591+
If not None, overrides the global setting to allow or disallow large
592+
query results over the default size limit of 10 GB.
593+
594+
Returns:
595+
If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None.
596+
"""
597+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
555598

556599
def to_dict(
557600
self,

packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,49 @@ def to_markdown(
548548
Series in Markdown-friendly format.
549549
"""
550550
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
551+
552+
def to_csv(
553+
self,
554+
path_or_buf=None,
555+
sep=",",
556+
*,
557+
header: bool = True,
558+
index: bool = True,
559+
allow_large_results: Optional[bool] = None,
560+
) -> dict | list[dict]:
561+
"""
562+
Write object to a comma-separated values (csv) file.
563+
564+
**Examples:**
565+
566+
>>> import bigframes.pandas as bpd
567+
568+
>>> s = bpd.Series([1,2,3], name='my_series')
569+
>>> s.to_csv()
570+
\',my_series\\n0,1\\n1,2\\n2,3\\n\'
571+
572+
Args:
573+
path_or_buf (str, path object, file-like object, or None, default None):
574+
String, path object (implementing os.PathLike[str]), or file-like object
575+
implementing a write() function. If None, the result is returned as a string.
576+
If a non-binary file object is passed, it should be opened with newline='',
577+
disabling universal newlines. If a binary file object is passed,
578+
mode might need to contain a 'b'.
579+
Must contain a wildcard character '*' if this is a GCS path.
580+
sep (str, default ','):
581+
String of length 1. Field delimiter for the output file.
582+
header (bool, default True):
583+
Write out the column names.
584+
index (bool, default True):
585+
Write row names (index).
586+
allow_large_results (bool, default None):
587+
If not None, overrides the global setting to allow or disallow large
588+
query results over the default size limit of 10 GB.
589+
590+
Returns:
591+
If path_or_buf is None, returns the resulting csv format as a string. Otherwise returns None.
592+
"""
593+
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
551594

552595
def to_dict(
553596
self,

0 commit comments

Comments
 (0)