From 3584448ab22c194d6d2a7e8b7dbdbb6c2eac5ded Mon Sep 17 00:00:00 2001 From: phofl Date: Mon, 14 Feb 2022 20:49:53 +0100 Subject: [PATCH] DOCS: Add comment about index_col and forward filling missing values --- doc/source/user_guide/io.rst | 4 ++++ pandas/io/excel/_base.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 34f10c1b3ec28..f11b6af24e4e4 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -3675,6 +3675,10 @@ should be passed to ``index_col`` and ``header``: os.remove("path_to_file.xlsx") +Missing values in columns specified in ``index_col`` will be forward filled to +allow roundtripping with ``to_excel`` for ``merged_cells=True``. To avoid forward +filling the missing values use ``set_index`` after reading the data instead of +``index_col``. Parsing specific columns ++++++++++++++++++++++++ diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index c32f84d41ebde..5bc51a6358c0a 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -119,6 +119,11 @@ those columns will be combined into a ``MultiIndex``. If a subset of data is selected with ``usecols``, index_col is based on the subset. + + Missing values will be forward filled to allow roundtripping with + ``to_excel`` for ``merged_cells=True``. To avoid forward filling the + missing values use ``set_index`` after reading the data instead of + ``index_col``. usecols : str, list-like, or callable, default None * If None, then parse all columns. * If str, then indicates comma separated list of Excel column letters