Skip to content

CI: Fix version openpyxl #29862

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 26, 2019
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ dependencies:
- fastparquet>=0.3.2 # pandas.read_parquet, DataFrame.to_parquet
- html5lib # pandas.read_html
- lxml # pandas.read_html
- openpyxl # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile
- openpyxl<=3.0.1 # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile
- pyarrow>=0.13.1 # pandas.read_parquet, DataFrame.to_parquet, pandas.read_feather, DataFrame.to_feather
- pyqt>=5.9.2 # pandas.read_clipboard
- pytables>=3.4.2 # pandas.read_hdf, DataFrame.to_hdf
Expand Down
22 changes: 22 additions & 0 deletions pandas/tests/io/excel/test_openpyxl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os

import numpy as np
import pytest

import pandas as pd
from pandas import DataFrame
import pandas.util.testing as tm

Expand Down Expand Up @@ -101,3 +105,21 @@ def test_write_append_mode(ext, mode, expected):

for index, cell_value in enumerate(expected):
assert wb2.worksheets[index]["A1"].value == cell_value


@pytest.mark.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl")
def test_to_excel_with_openpyxl_engine(ext, tmpdir):
# GH 29854
# TODO: Fix this once newer version of openpyxl fixes the bug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlesdong1991 any idea if this TODO can be addressed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this xfail should be removed!! new version of openpyxl has fixed the issue @jbrockmendel

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

emm, seems have been removed on master.

df1 = DataFrame({"A": np.linspace(1, 10, 10)})
df2 = DataFrame({"B": np.linspace(1, 20, 10)})
df = pd.concat([df1, df2], axis=1)
styled = df.style.applymap(
lambda val: "color: %s" % "red" if val < 0 else "black"
).highlight_max()

filename = tmpdir / "styled.xlsx"
styled.to_excel(filename, engine="openpyxl")

assert filename.exists()
os.remove(filename)
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ beautifulsoup4>=4.6.0
fastparquet>=0.3.2
html5lib
lxml
openpyxl
openpyxl<=3.0.1
pyarrow>=0.13.1
pyqt5>=5.9.2
tables>=3.4.2
Expand Down