Skip to content

Commit 789cdd8

Browse files
charlesdong1991proost
authored andcommitted
CI: Fix version openpyxl (pandas-dev#29862)
* remove \n from docstring * avoid upgrade * limit version * Add test and skip it for higher version * resort imports * change to xfail * fix typo * add ext * fix test * fix path * better check
1 parent 2267399 commit 789cdd8

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ dependencies:
7878
- fastparquet>=0.3.2 # pandas.read_parquet, DataFrame.to_parquet
7979
- html5lib # pandas.read_html
8080
- lxml # pandas.read_html
81-
- openpyxl # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile
81+
- openpyxl<=3.0.1 # pandas.read_excel, DataFrame.to_excel, pandas.ExcelWriter, pandas.ExcelFile
8282
- pyarrow>=0.13.1 # pandas.read_parquet, DataFrame.to_parquet, pandas.read_feather, DataFrame.to_feather
8383
- pyqt>=5.9.2 # pandas.read_clipboard
8484
- pytables>=3.4.2 # pandas.read_hdf, DataFrame.to_hdf

pandas/tests/io/excel/test_openpyxl.py

+22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import os
2+
3+
import numpy as np
14
import pytest
25

6+
import pandas as pd
37
from pandas import DataFrame
48
import pandas.util.testing as tm
59

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

102106
for index, cell_value in enumerate(expected):
103107
assert wb2.worksheets[index]["A1"].value == cell_value
108+
109+
110+
@pytest.mark.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl")
111+
def test_to_excel_with_openpyxl_engine(ext, tmpdir):
112+
# GH 29854
113+
# TODO: Fix this once newer version of openpyxl fixes the bug
114+
df1 = DataFrame({"A": np.linspace(1, 10, 10)})
115+
df2 = DataFrame({"B": np.linspace(1, 20, 10)})
116+
df = pd.concat([df1, df2], axis=1)
117+
styled = df.style.applymap(
118+
lambda val: "color: %s" % "red" if val < 0 else "black"
119+
).highlight_max()
120+
121+
filename = tmpdir / "styled.xlsx"
122+
styled.to_excel(filename, engine="openpyxl")
123+
124+
assert filename.exists()
125+
os.remove(filename)

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ beautifulsoup4>=4.6.0
5151
fastparquet>=0.3.2
5252
html5lib
5353
lxml
54-
openpyxl
54+
openpyxl<=3.0.1
5555
pyarrow>=0.13.1
5656
pyqt5>=5.9.2
5757
tables>=3.4.2

0 commit comments

Comments
 (0)