Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a8fccef

Browse filesBrowse files
authored
docs(bigframes): Add docs to the to_csv methods of dataframe and series (#16570)
Also reformatted two files under `rewrite/` dir to make the linter happy. Fixes b/498602137 🦕
1 parent 2f792ab commit a8fccef
Copy full SHA for a8fccef

4 files changed

+89-2Lines changed: 89 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/bigframes/bigframes/core/rewrite/__init__.py‎

Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/core/rewrite/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from bigframes.core.rewrite.identifiers import remap_variables
1919
from bigframes.core.rewrite.implicit_align import try_row_join
2020
from bigframes.core.rewrite.legacy_align import legacy_join_as_projection
21+
from bigframes.core.rewrite.nullity import simplify_join
2122
from bigframes.core.rewrite.order import bake_order, defer_order
2223
from bigframes.core.rewrite.pruning import column_pruning
2324
from bigframes.core.rewrite.scan_reduction import (
@@ -33,7 +34,6 @@
3334
rewrite_range_rolling,
3435
simplify_complex_windows,
3536
)
36-
from bigframes.core.rewrite.nullity import simplify_join
3737

3838
__all__ = [
3939
"as_sql_nodes",
Collapse file

‎packages/bigframes/bigframes/core/rewrite/nullity.py‎

Copy file name to clipboardExpand all lines: packages/bigframes/bigframes/core/rewrite/nullity.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
from __future__ import annotations
1616

17-
from bigframes.core import nodes
1817
import dataclasses
1918

19+
from bigframes.core import nodes
20+
2021

2122
def simplify_join(node: nodes.BigFrameNode) -> nodes.BigFrameNode:
2223
"""Simplify a join node by removing nullity checks."""
Collapse file

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

Copy file name to clipboardExpand all lines: packages/bigframes/third_party/bigframes_vendored/pandas/core/frame.py
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,49 @@ def to_parquet(
553553
"""
554554
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
555555

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+
) -> Optional[str]:
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)
598+
556599
def to_dict(
557600
self,
558601
orient: Literal[
Collapse file

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

Copy file name to clipboardExpand all lines: packages/bigframes/third_party/bigframes_vendored/pandas/core/series.py
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,49 @@ def to_markdown(
549549
"""
550550
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
551551

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+
) -> Optional[str]:
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)
594+
552595
def to_dict(
553596
self,
554597
into: type[dict] = dict,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.