From 13663c477a88cb341a500e5625b30ec43b1f221f Mon Sep 17 00:00:00 2001 From: Yashpal Ahlawat Date: Sat, 24 Feb 2024 16:46:46 +0530 Subject: [PATCH 1/4] ES01 fix for to_csv method --- ci/code_checks.sh | 1 - pandas/core/generic.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index f1e7f6d477906..11257a49761ad 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -476,7 +476,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.DataFrame.sparse.from_spmatrix\ pandas.DataFrame.sparse.to_coo\ pandas.DataFrame.sparse.to_dense\ - pandas.DataFrame.to_csv\ pandas.DataFrame.to_feather\ pandas.DataFrame.to_html\ pandas.DataFrame.to_markdown\ diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 0880e6730fd93..5b74904da1919 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3672,6 +3672,18 @@ def to_csv( r""" Write object to a comma-separated values (csv) file. + This method enables users to export DataFrame data to a CSV file + with customizable options. These options include specifying the delimiter, + handling missing data, formatting numbers,selecting columns, including headers + and row names, defining file opening modes, setting encoding and + compression options, controlling quoting and escaping characters, + specifying newline characters, managing chunk sizes, formatting + datetime objects, handling errors during encoding/decoding, + and providing storage connection options. + + The method returns None if path_or_buf is not specified; + otherwise, it returns the resulting CSV format as a string. + Parameters ---------- path_or_buf : str, path object, file-like object, or None, default None From 01a452ef85d3a3566a95151d0ccc17c95263caed Mon Sep 17 00:00:00 2001 From: Yashpal Ahlawat Date: Sat, 24 Feb 2024 17:54:05 +0530 Subject: [PATCH 2/4] updated to better wording --- pandas/core/generic.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 5b74904da1919..46e1a2a824ec6 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3672,14 +3672,13 @@ def to_csv( r""" Write object to a comma-separated values (csv) file. - This method enables users to export DataFrame data to a CSV file + This method enables users to write object to comma-separated values (csv) file with customizable options. These options include specifying the delimiter, - handling missing data, formatting numbers,selecting columns, including headers - and row names, defining file opening modes, setting encoding and - compression options, controlling quoting and escaping characters, - specifying newline characters, managing chunk sizes, formatting - datetime objects, handling errors during encoding/decoding, - and providing storage connection options. + handling missing data, formatting numbers, selecting columns, including + headers and row names, defining file opening modes, setting encoding and + compression options, controlling quoting and escaping characters, specifying + newline characters, managing chunk sizes, formatting datetime objects, handling + errors during encoding/decoding, and providing storage connection options. The method returns None if path_or_buf is not specified; otherwise, it returns the resulting CSV format as a string. From 9ec0c5a4bb41dc7396c09720e655608da2b22f49 Mon Sep 17 00:00:00 2001 From: Yashpal Ahlawat Date: Sun, 25 Feb 2024 13:37:40 +0530 Subject: [PATCH 3/4] review comments implemented --- pandas/core/generic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 46e1a2a824ec6..1b367e091058b 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3670,9 +3670,9 @@ def to_csv( storage_options: StorageOptions | None = None, ) -> str | None: r""" - Write object to a comma-separated values (csv) file. + Write object to a comma-separated values (CSV) file. - This method enables users to write object to comma-separated values (csv) file + This method enables users to write object to comma-separated values (CSV) file with customizable options. These options include specifying the delimiter, handling missing data, formatting numbers, selecting columns, including headers and row names, defining file opening modes, setting encoding and @@ -3680,7 +3680,7 @@ def to_csv( newline characters, managing chunk sizes, formatting datetime objects, handling errors during encoding/decoding, and providing storage connection options. - The method returns None if path_or_buf is not specified; + The method returns None if `path_or_buf` is not specified; otherwise, it returns the resulting CSV format as a string. Parameters From 7a8334c27b975cc6071c0a20a32b64919bf9f993 Mon Sep 17 00:00:00 2001 From: Yashpal Ahlawat Date: Sun, 25 Feb 2024 13:46:24 +0530 Subject: [PATCH 4/4] review comments implemented --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 1b367e091058b..f9cbce12e9da9 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3680,7 +3680,7 @@ def to_csv( newline characters, managing chunk sizes, formatting datetime objects, handling errors during encoding/decoding, and providing storage connection options. - The method returns None if `path_or_buf` is not specified; + The method returns None if ``path_or_buf`` is not specified; otherwise, it returns the resulting CSV format as a string. Parameters