Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,15 @@ of multi-columns indices.
with ``df.to_csv(..., index=False)``), then any ``names`` on the columns index will
be *lost*.

.. warning::
When a ``DataFrame`` with ``MultiIndex`` columns has an *unnamed* index, the row
that would hold the index names is omitted on write. If the first data row then
consists entirely of missing values, it is written identically to that omitted
row, and on read ``read_csv`` cannot tell the two apart: it consumes the first
data row as the index names, silently dropping that row. Avoid this by writing
missing values with a non-empty ``na_rep`` (e.g. ``df.to_csv(na_rep="NaN")``) or
by giving the index a name.

.. ipython:: python
:suppress:

Expand Down