From f2a7e0e703f962bc8841eaaa1717379a61b29709 Mon Sep 17 00:00:00 2001 From: Konjeti Maruthi <63769209+MaruthiKo@users.noreply.github.com> Date: Wed, 25 May 2022 23:52:47 +0530 Subject: [PATCH 1/7] Changes as requested in #47058 This is my first open-source contribution. Please let me know if there are any mistakes, will rectify them --- pandas/core/generic.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 1f524d07bfd3a..19d7369bc3839 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3300,7 +3300,7 @@ def to_csv( header: bool_t | list[str] = True, index: bool_t = True, index_label: IndexLabel | None = None, - mode: str = "w", + mode: str = "a", encoding: str | None = None, compression: CompressionOptions = "infer", quoting: int | None = None, @@ -3349,8 +3349,11 @@ def to_csv( sequence should be given if the object uses MultiIndex. If False do not print fields for index names. Use index_label=False for easier importing in R. - mode : str - Python write mode, default 'w'. + mode : str, default 'w' + String character(s) to indicate the mode in which the file is opened for writing. Valid + values include: 'w' for "write" access, 'w+' or 'r+' for read and write access, 'x' or 'x+' for + exclusive creation access, and 'a' or 'a+' for append access. All strings have an implied 't' + for text access; binary access is not permitted. encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From a45012e0501ec95fc54db9c10c20ebc35227592d Mon Sep 17 00:00:00 2001 From: Konjeti Maruthi <63769209+MaruthiKo@users.noreply.github.com> Date: Thu, 26 May 2022 00:00:38 +0530 Subject: [PATCH 2/7] required changes as per #47058 Please let me know if have to change anything. --- pandas/core/generic.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 19d7369bc3839..2777f58e3fb07 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3300,7 +3300,7 @@ def to_csv( header: bool_t | list[str] = True, index: bool_t = True, index_label: IndexLabel | None = None, - mode: str = "a", + mode: str = "w", encoding: str | None = None, compression: CompressionOptions = "infer", quoting: int | None = None, @@ -3350,10 +3350,11 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - String character(s) to indicate the mode in which the file is opened for writing. Valid - values include: 'w' for "write" access, 'w+' or 'r+' for read and write access, 'x' or 'x+' for - exclusive creation access, and 'a' or 'a+' for append access. All strings have an implied 't' - for text access; binary access is not permitted. + String character(s) to indicate the mode in which the file is opened for + writing. Valid values include: 'w' for "write" access, 'w+' or 'r+' for + read and write access, 'x' or 'x+' for exclusive creation access, and 'a' or 'a+' + for append access. All strings have an implied 't' for text access; + binary access is not permitted. encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From be1201b1bc2f8d7be966f9f11d08b1894cbe3cc5 Mon Sep 17 00:00:00 2001 From: Konjeti Maruthi <63769209+MaruthiKo@users.noreply.github.com> Date: Thu, 26 May 2022 00:37:55 +0530 Subject: [PATCH 3/7] changes to doc as per #47058 If any more changes required please let me know. --- pandas/core/generic.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2777f58e3fb07..6dacc6822d800 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3350,11 +3350,7 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - String character(s) to indicate the mode in which the file is opened for - writing. Valid values include: 'w' for "write" access, 'w+' or 'r+' for - read and write access, 'x' or 'x+' for exclusive creation access, and 'a' or 'a+' - for append access. All strings have an implied 't' for text access; - binary access is not permitted. + Python write mode. The available write modes are the same as :py:func:`open` encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From d4400f2f968c16eda733047f862dc7e9b971e061 Mon Sep 17 00:00:00 2001 From: Konjeti Maruthi <63769209+MaruthiKo@users.noreply.github.com> Date: Thu, 26 May 2022 00:50:11 +0530 Subject: [PATCH 4/7] Changes to doc as per #47058 Let me know if there are any changes --- 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 6dacc6822d800..144ee2aed261c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3350,7 +3350,7 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - Python write mode. The available write modes are the same as :py:func:`open` + Python write mode. The available write modes are the same as :py:func:`open` encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From 7be4fa4535dec72a8bc102191cf91915d268ddf8 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Wed, 25 May 2022 12:49:28 -0700 Subject: [PATCH 5/7] Update pandas/core/generic.py --- 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 144ee2aed261c..d781d45483acb 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3350,7 +3350,7 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - Python write mode. The available write modes are the same as :py:func:`open` + Python write mode. The available write modes are the same as :py:func:`open`. encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From bcbc0dbf4398bc26c7158e3197a728f310896c71 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Wed, 25 May 2022 13:20:01 -0700 Subject: [PATCH 6/7] Update pandas/core/generic.py --- pandas/core/generic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d781d45483acb..ed128e3f07e69 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3350,7 +3350,8 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - Python write mode. The available write modes are the same as :py:func:`open`. + Python write mode. The available write modes are the same as + :py:func:`open`. encoding : str, optional A string representing the encoding to use in the output file, defaults to 'utf-8'. `encoding` is not supported if `path_or_buf` From 10014d47acd5bea8295afa30ffd59d22c231db3c Mon Sep 17 00:00:00 2001 From: Matthew Roeschke Date: Wed, 25 May 2022 13:37:39 -0700 Subject: [PATCH 7/7] Update pandas/core/generic.py --- 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 ed128e3f07e69..2fc137a85daaf 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3350,7 +3350,7 @@ def to_csv( False do not print fields for index names. Use index_label=False for easier importing in R. mode : str, default 'w' - Python write mode. The available write modes are the same as + Python write mode. The available write modes are the same as :py:func:`open`. encoding : str, optional A string representing the encoding to use in the output file,