Skip to content

DOC: Improve to_csv mode documentation #51839

Closed
@MrPowers

Description

@MrPowers

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_csv.html

Documentation problem

The to_csv mode method does not explicitly list the options for users. It links to the Python open() method that contains some options that aren't relevant.

Suggested fix for documentation

It'd be nice to list the mode options right in the to_csv docs. This should be significantly more user-friendly. Suggested text:

mode: str, default ‘w’

The file write mode which can be `w`, `x`, or `a`.  `w` will write the file and overwrite another file if it already exists.  `x` will write the file, but error out if a file with the same name already exists.  `a` will append to the existing file.

The available write modes are the same as [open()](https://docs.python.org/3/library/functions.html#open).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions