Skip to content

DOC update DataFrame.to_csv write modes (#51839) #51881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 17, 2023
14 changes: 11 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3635,9 +3635,17 @@ 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, default 'w'
Python write mode. The available write modes are the same as
:py:func:`open`.
mode : {{'w', 'x', 'a'}}, default 'w'
Forwarded to either `open(mode=)` or `fsspec.open(mode=)` to control
the file opening. Typical values include:

- 'w', open for writing, truncating the file first.
- 'x', open for exclusive creation, failing if the file already exists.
- 'a', open for writing, appending to the end of file if it exists.

Including 'b' or 't' in the mode parameter will inform Pandas whether
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use pandas lowercase.

'path_or_buf' requires string or binary data. However, in most cases,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think path_or_buf needs backticks. I'm not sure whether the quoted strings should also be wrapped in backticks.

this should not be necessary.
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`
Expand Down