You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.20.0.txt
+13-4
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ Highlights include:
17
17
- Improved user API when accessing levels in ``.groupby()``, see :ref:`here <whatsnew_0200.enhancements.groupby_access>`
18
18
- Improved support for ``UInt64`` dtypes, see :ref:`here <whatsnew_0200.enhancements.uint64_support>`
19
19
- A new orient for JSON serialization, ``orient='table'``, that uses the :ref:`Table Schema spec <whatsnew_0200.enhancements.table_schema>`
20
+
- Experimental support for exporting ``DataFrame.style`` formats to Excel , see :ref:`here <whatsnew_0200.enhancements.style_excel>`
20
21
- Window Binary Corr/Cov operations now return a MultiIndexed ``DataFrame`` rather than a ``Panel``, as ``Panel`` is now deprecated, see :ref:`here <whatsnew_0200.api_breaking.rolling_pairwise>`
21
22
- Support for S3 handling now uses ``s3fs``, see :ref:`here <whatsnew_0200.api_breaking.s3>`
22
23
- Google BigQuery support now uses the ``pandas-gbq`` library, see :ref:`here <whatsnew_0200.api_breaking.gbq>`
@@ -403,7 +404,7 @@ To convert a ``SparseDataFrame`` back to sparse SciPy matrix in COO format, you
403
404
Excel output for styled DataFrames
404
405
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
405
406
406
-
Experimental support has been added to export ``DataFrame.style`` to Excel using the ``openpyxl`` engine. (:issue:`15530`)
407
+
Experimental support has been added to export ``DataFrame.style`` formats to Excel using the ``openpyxl`` engine. (:issue:`15530`)
407
408
408
409
For example, after running the following, ``styled.xlsx`` renders as below:
409
410
@@ -415,16 +416,24 @@ For example, after running the following, ``styled.xlsx`` renders as below:
415
416
columns=list('BCDE'))],
416
417
axis=1)
417
418
df.iloc[0, 2] = np.nan
418
-
df.style.\
419
+
styled = df.style.\
419
420
applymap(lambda val: 'color: %s' % 'red' if val < 0 else 'black').\
420
421
apply(lambda s: ['background-color: yellow' if v else ''
421
-
for v in s == s.max()]).\
422
-
to_excel('styled.xlsx', engine='openpyxl')
422
+
for v in s == s.max()])
423
+
styled
424
+
styled.to_excel('styled.xlsx', engine='openpyxl')
423
425
424
426
.. image:: _static/style-excel.png
425
427
428
+
.. ipython:: python
429
+
:suppress:
430
+
import os
431
+
os.remove('styled.xlsx')
432
+
426
433
See the :ref:`Style documentation <style>` for more detail.
0 commit comments