From 6168765972cb3c2f8df45cbb791ce2dd8cc4c5e1 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Thu, 20 Apr 2017 00:25:45 +1000 Subject: [PATCH] Recommended changes to what's new --- doc/source/whatsnew/v0.20.0.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index c3fbbcf542daf..8834a4f578006 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -17,6 +17,7 @@ Highlights include: - Improved user API when accessing levels in ``.groupby()``, see :ref:`here ` - Improved support for ``UInt64`` dtypes, see :ref:`here ` - A new orient for JSON serialization, ``orient='table'``, that uses the :ref:`Table Schema spec ` +- Experimental support for exporting ``DataFrame.style`` formats to Excel , see :ref:`here ` - Window Binary Corr/Cov operations now return a MultiIndexed ``DataFrame`` rather than a ``Panel``, as ``Panel`` is now deprecated, see :ref:`here ` - Support for S3 handling now uses ``s3fs``, see :ref:`here ` - Google BigQuery support now uses the ``pandas-gbq`` library, see :ref:`here ` @@ -403,7 +404,7 @@ To convert a ``SparseDataFrame`` back to sparse SciPy matrix in COO format, you Excel output for styled DataFrames ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Experimental support has been added to export ``DataFrame.style`` to Excel using the ``openpyxl`` engine. (:issue:`15530`) +Experimental support has been added to export ``DataFrame.style`` formats to Excel using the ``openpyxl`` engine. (:issue:`15530`) For example, after running the following, ``styled.xlsx`` renders as below: @@ -415,16 +416,24 @@ For example, after running the following, ``styled.xlsx`` renders as below: columns=list('BCDE'))], axis=1) df.iloc[0, 2] = np.nan - df.style.\ + styled = df.style.\ applymap(lambda val: 'color: %s' % 'red' if val < 0 else 'black').\ apply(lambda s: ['background-color: yellow' if v else '' - for v in s == s.max()]).\ - to_excel('styled.xlsx', engine='openpyxl') + for v in s == s.max()]) + styled + styled.to_excel('styled.xlsx', engine='openpyxl') .. image:: _static/style-excel.png +.. ipython:: python + :suppress: + import os + os.remove('styled.xlsx') + See the :ref:`Style documentation