Skip to content

Commit 94ac0b7

Browse files
committed
DOC update DataFrame.to_csv write modes (pandas-dev#51839)
Modify write mode descriptions and add an explanation for b and t mode.
1 parent 2262c56 commit 94ac0b7

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

pandas/core/generic.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,18 +3631,16 @@ def to_csv(
36313631
False do not print fields for index names. Use index_label=False
36323632
for easier importing in R.
36333633
mode : {{'w', 'x', 'a'}}, default 'w'
3634-
Python write mode. The available write modes are:
3635-
3636-
- 'w', opens the file for writing and truncates the file if it
3637-
already exists. If the file does not exist, it creates a new
3638-
file.
3639-
- 'x', opens the file for exclusive creation, meaning it will fail
3640-
if the file already exists. If the file does not exist, it
3641-
creates a new file.
3642-
- 'a', opens the file for writing in append mode. The data is
3643-
written to the end of the file, without truncating it. If the
3644-
file does not exist, it creates a new file.
3634+
Forwarded to either `open(mode=)` or `fsspec.open(mode=)` to control
3635+
the file opening. Typical values include:
36453636
3637+
- 'w', open for writing, truncating the file first.
3638+
- 'x', open for exclusive creation, failing if the file already exists.
3639+
- 'a', open for writing, appending to the end of file if it exists.
3640+
3641+
Including 'b' or 't' in the mode parameter will inform Pandas whether
3642+
'path_or_buf' requires string or binary data. However, in most cases,
3643+
this should not be necessary.
36463644
encoding : str, optional
36473645
A string representing the encoding to use in the output file,
36483646
defaults to 'utf-8'. `encoding` is not supported if `path_or_buf`

0 commit comments

Comments
 (0)