From fd2366f1be44d6ed58418ba8b57cf0956e47b8fe Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:05:54 +0100 Subject: [PATCH 1/5] DOC: add simple example to DataFrame.to_csv() --- 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 e6dcb634f7947..fe45fbfcdf4ab 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3950,14 +3950,14 @@ def to_csv( Examples -------- + Create 'out.csv' containing 'df' without indices >>> df = pd.DataFrame({{'name': ['Raphael', 'Donatello'], ... 'mask': ['red', 'purple'], ... 'weapon': ['sai', 'bo staff']}}) - >>> df.to_csv(index=False) - 'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n' + >>> df.to_csv('out.csv', index=False) Create 'out.zip' containing 'out.csv' - + >>> df.to_csv(index=False) >>> compression_opts = dict(method='zip', ... archive_name='out.csv') # doctest: +SKIP >>> df.to_csv('out.zip', index=False, From fafd4f23ee0cb34326b4eceb610915bd64e4c3f2 Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Tue, 5 Dec 2023 16:28:33 +0100 Subject: [PATCH 2/5] update --- pandas/core/generic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index fe45fbfcdf4ab..b7e0002bb89d8 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3958,6 +3958,7 @@ def to_csv( Create 'out.zip' containing 'out.csv' >>> df.to_csv(index=False) + 'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n' >>> compression_opts = dict(method='zip', ... archive_name='out.csv') # doctest: +SKIP >>> df.to_csv('out.zip', index=False, From 9b194c566b531befa8ba28685a9a1c3b245d915f Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Tue, 5 Dec 2023 17:01:22 +0100 Subject: [PATCH 3/5] add doctest skip --- pandas/core/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index b7e0002bb89d8..233d79c61304a 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3950,13 +3950,13 @@ def to_csv( Examples -------- - Create 'out.csv' containing 'df' without indices + Create 'out.csv' containing 'df' without indices # doctest: +SKIP >>> df = pd.DataFrame({{'name': ['Raphael', 'Donatello'], ... 'mask': ['red', 'purple'], ... 'weapon': ['sai', 'bo staff']}}) >>> df.to_csv('out.csv', index=False) - Create 'out.zip' containing 'out.csv' + Create 'out.zip' containing 'out.csv' # doctest: +SKIP >>> df.to_csv(index=False) 'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n' >>> compression_opts = dict(method='zip', From 6977298f114b27d9664c5d60c57ababa9edb26c9 Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:21:01 +0100 Subject: [PATCH 4/5] Update pandas/core/generic.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- 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 233d79c61304a..442518cfbb8f3 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3950,7 +3950,8 @@ def to_csv( Examples -------- - Create 'out.csv' containing 'df' without indices # doctest: +SKIP + Create 'out.csv' containing 'df' without indices + >>> df = pd.DataFrame({{'name': ['Raphael', 'Donatello'], ... 'mask': ['red', 'purple'], ... 'weapon': ['sai', 'bo staff']}}) From 289c39cb13ea1aca41e235b827377d39969f651e Mon Sep 17 00:00:00 2001 From: Linus <95619282+linus-md@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:21:13 +0100 Subject: [PATCH 5/5] Update pandas/core/generic.py Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- pandas/core/generic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 442518cfbb8f3..a1617934ccb29 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3955,9 +3955,10 @@ def to_csv( >>> df = pd.DataFrame({{'name': ['Raphael', 'Donatello'], ... 'mask': ['red', 'purple'], ... 'weapon': ['sai', 'bo staff']}}) - >>> df.to_csv('out.csv', index=False) + >>> df.to_csv('out.csv', index=False) # doctest: +SKIP + + Create 'out.zip' containing 'out.csv' - Create 'out.zip' containing 'out.csv' # doctest: +SKIP >>> df.to_csv(index=False) 'name,mask,weapon\nRaphael,red,sai\nDonatello,purple,bo staff\n' >>> compression_opts = dict(method='zip',