From 7e461a18d9f6928132afec6f48ce968b3e989ba6 Mon Sep 17 00:00:00 2001 From: Kaiqi Dong Date: Mon, 3 Dec 2018 17:43:52 +0100 Subject: [PATCH 01/11] remove \n from docstring --- pandas/core/arrays/datetimes.py | 26 +++++++++++++------------- pandas/core/arrays/timedeltas.py | 16 ++++++++-------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index cfe3afcf3730a..b3df505d56d78 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -82,7 +82,7 @@ def f(self): return result f.__name__ = name - f.__doc__ = docstring + f.__doc__ = "\n{}\n".format(docstring) return property(f) @@ -1072,19 +1072,19 @@ def date(self): return tslib.ints_to_pydatetime(timestamps, box="date") - year = _field_accessor('year', 'Y', "\n The year of the datetime\n") + year = _field_accessor('year', 'Y', "The year of the datetime") month = _field_accessor('month', 'M', - "\n The month as January=1, December=12 \n") - day = _field_accessor('day', 'D', "\nThe days of the datetime\n") - hour = _field_accessor('hour', 'h', "\nThe hours of the datetime\n") - minute = _field_accessor('minute', 'm', "\nThe minutes of the datetime\n") - second = _field_accessor('second', 's', "\nThe seconds of the datetime\n") + "The month as January=1, December=12") + day = _field_accessor('day', 'D', "The days of the datetime") + hour = _field_accessor('hour', 'h', "The hours of the datetime") + minute = _field_accessor('minute', 'm', "The minutes of the datetime") + second = _field_accessor('second', 's', "The seconds of the datetime") microsecond = _field_accessor('microsecond', 'us', - "\nThe microseconds of the datetime\n") + "The microseconds of the datetime") nanosecond = _field_accessor('nanosecond', 'ns', - "\nThe nanoseconds of the datetime\n") + "The nanoseconds of the datetime") weekofyear = _field_accessor('weekofyear', 'woy', - "\nThe week ordinal of the year\n") + "The week ordinal of the year") week = weekofyear _dayofweek_doc = """ The day of the week with Monday=0, Sunday=6. @@ -1129,12 +1129,12 @@ def date(self): "The name of day in a week (ex: Friday)\n\n.. deprecated:: 0.23.0") dayofyear = _field_accessor('dayofyear', 'doy', - "\nThe ordinal day of the year\n") - quarter = _field_accessor('quarter', 'q', "\nThe quarter of the date\n") + "The ordinal day of the year") + quarter = _field_accessor('quarter', 'q', "The quarter of the date") days_in_month = _field_accessor( 'days_in_month', 'dim', - "\nThe number of days in the month\n") + "The number of days in the month") daysinmonth = days_in_month _is_month_doc = """ Indicates whether the date is the {first_or_last} day of the month. diff --git a/pandas/core/arrays/timedeltas.py b/pandas/core/arrays/timedeltas.py index 830283d31a929..4afc9f5483c2a 100644 --- a/pandas/core/arrays/timedeltas.py +++ b/pandas/core/arrays/timedeltas.py @@ -59,7 +59,7 @@ def f(self): return result f.__name__ = name - f.__doc__ = docstring + f.__doc__ = "\n{}\n".format(docstring) return property(f) @@ -684,16 +684,16 @@ def to_pytimedelta(self): return tslibs.ints_to_pytimedelta(self.asi8) days = _field_accessor("days", "days", - "\nNumber of days for each element.\n") + "Number of days for each element.") seconds = _field_accessor("seconds", "seconds", - "\nNumber of seconds (>= 0 and less than 1 day) " - "for each element.\n") + "Number of seconds (>= 0 and less than 1 day) " + "for each element.") microseconds = _field_accessor("microseconds", "microseconds", - "\nNumber of microseconds (>= 0 and less " - "than 1 second) for each element.\n") + "Number of microseconds (>= 0 and less " + "than 1 second) for each element.") nanoseconds = _field_accessor("nanoseconds", "nanoseconds", - "\nNumber of nanoseconds (>= 0 and less " - "than 1 microsecond) for each element.\n") + "Number of nanoseconds (>= 0 and less " + "than 1 microsecond) for each element.") @property def components(self): From f79f2b1992a9e8151d8a06f0355e00e515c86d98 Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 17:46:25 +0100 Subject: [PATCH 02/11] avoid upgrade --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 4d0e7ee904294..5f67726a3e476 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -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 From 8305b990db85867c3df032d4e065e14dce5cac51 Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 18:09:38 +0100 Subject: [PATCH 03/11] limit version --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index 848825c37a160..2b171d097a693 100644 --- a/environment.yml +++ b/environment.yml @@ -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 From e90a82db189ee4244faae2d5f976bfd15c81307b Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 20:36:19 +0100 Subject: [PATCH 04/11] Add test and skip it for higher version --- pandas/tests/io/excel/test_openpyxl.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index e9b4a5d4e430d..71e316881d2c8 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -1,5 +1,7 @@ import pytest +import pandas as pd +import numpy as np from pandas import DataFrame import pandas.util.testing as tm @@ -101,3 +103,20 @@ def test_write_append_mode(ext, mode, expected): for index, cell_value in enumerate(expected): assert wb2.worksheets[index]["A1"].value == cell_value + + +@pytest.skip(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") +def test_to_excel_with_openpyxl_engine(tmpdir): + # GH 29854 + # TODO: Fix this once newer version of openpyxl fixes the bug + df1 = DataFrame({"A": np.linspace(1, 10, 10)}) + df2 = DataFrame({"B": np.linspace(1, 20, 10)}) + df = pd.concat([df1, df2], axis=1) + df.iloc[0, 2] = np.nan + styled = df.style.applymap( + lambda val: "color: %s" % "red" if val < 0 else "black" + ).highlight_max() + filename = tmpdir.join("styled.xlsx") + styled.to_excel(filename, engine="openpyxl") + + assert "styled.xlsx" in tmpdir.listdir() From 62cd6812eebc17f48df9ec6c7ffadc687288bb0b Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 20:37:05 +0100 Subject: [PATCH 05/11] resort imports --- pandas/tests/io/excel/test_openpyxl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index 71e316881d2c8..3bb318e133db9 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -1,7 +1,7 @@ +import numpy as np import pytest import pandas as pd -import numpy as np from pandas import DataFrame import pandas.util.testing as tm From a2153c648e07e0d5ddbaf72720ad09a8fad6de9c Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 20:48:11 +0100 Subject: [PATCH 06/11] change to xfail --- pandas/tests/io/excel/test_openpyxl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index 3bb318e133db9..ffeb49528ca93 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -105,7 +105,7 @@ def test_write_append_mode(ext, mode, expected): assert wb2.worksheets[index]["A1"].value == cell_value -@pytest.skip(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") +@pytest.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") def test_to_excel_with_openpyxl_engine(tmpdir): # GH 29854 # TODO: Fix this once newer version of openpyxl fixes the bug From 66fe4a873eda8e5722fa13208ce92ef8553106ab Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 21:13:15 +0100 Subject: [PATCH 07/11] fix typo --- pandas/tests/io/excel/test_openpyxl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index ffeb49528ca93..ba2a94da3bcf6 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -105,7 +105,7 @@ def test_write_append_mode(ext, mode, expected): assert wb2.worksheets[index]["A1"].value == cell_value -@pytest.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") +@pytest.mark.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") def test_to_excel_with_openpyxl_engine(tmpdir): # GH 29854 # TODO: Fix this once newer version of openpyxl fixes the bug From 2299ab9d930ac3d8a4010e20ff8236f49a545d89 Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 21:40:01 +0100 Subject: [PATCH 08/11] add ext --- pandas/tests/io/excel/test_openpyxl.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index ba2a94da3bcf6..83fabb78496f8 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -1,3 +1,5 @@ +import os + import numpy as np import pytest @@ -106,7 +108,7 @@ def test_write_append_mode(ext, mode, expected): @pytest.mark.xfail(openpyxl.__version__ > "3.0.1", reason="broken change in openpyxl") -def test_to_excel_with_openpyxl_engine(tmpdir): +def test_to_excel_with_openpyxl_engine(ext, tmpdir): # GH 29854 # TODO: Fix this once newer version of openpyxl fixes the bug df1 = DataFrame({"A": np.linspace(1, 10, 10)}) @@ -116,7 +118,9 @@ def test_to_excel_with_openpyxl_engine(tmpdir): styled = df.style.applymap( lambda val: "color: %s" % "red" if val < 0 else "black" ).highlight_max() + filename = tmpdir.join("styled.xlsx") styled.to_excel(filename, engine="openpyxl") assert "styled.xlsx" in tmpdir.listdir() + os.remove(filename) From a446ab5452ebb9eb59f0003b89b4a1f63981d7de Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 22:37:36 +0100 Subject: [PATCH 09/11] fix test --- pandas/tests/io/excel/test_openpyxl.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index 83fabb78496f8..49234ffe0ee80 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -114,7 +114,6 @@ def test_to_excel_with_openpyxl_engine(ext, tmpdir): df1 = DataFrame({"A": np.linspace(1, 10, 10)}) df2 = DataFrame({"B": np.linspace(1, 20, 10)}) df = pd.concat([df1, df2], axis=1) - df.iloc[0, 2] = np.nan styled = df.style.applymap( lambda val: "color: %s" % "red" if val < 0 else "black" ).highlight_max() From c52f28a6608ac56f7acdf87a8422fb85bc7309e3 Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 23:05:20 +0100 Subject: [PATCH 10/11] fix path --- pandas/tests/io/excel/test_openpyxl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index 49234ffe0ee80..da64b63e77aea 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -121,5 +121,5 @@ def test_to_excel_with_openpyxl_engine(ext, tmpdir): filename = tmpdir.join("styled.xlsx") styled.to_excel(filename, engine="openpyxl") - assert "styled.xlsx" in tmpdir.listdir() + assert filename in tmpdir.listdir() os.remove(filename) From 893b1d404ffdd80bcb6a8491212a07f02ab37284 Mon Sep 17 00:00:00 2001 From: Kaiqi Date: Tue, 26 Nov 2019 23:07:05 +0100 Subject: [PATCH 11/11] better check --- pandas/tests/io/excel/test_openpyxl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/io/excel/test_openpyxl.py b/pandas/tests/io/excel/test_openpyxl.py index da64b63e77aea..f00329e9c7f81 100644 --- a/pandas/tests/io/excel/test_openpyxl.py +++ b/pandas/tests/io/excel/test_openpyxl.py @@ -118,8 +118,8 @@ def test_to_excel_with_openpyxl_engine(ext, tmpdir): lambda val: "color: %s" % "red" if val < 0 else "black" ).highlight_max() - filename = tmpdir.join("styled.xlsx") + filename = tmpdir / "styled.xlsx" styled.to_excel(filename, engine="openpyxl") - assert filename in tmpdir.listdir() + assert filename.exists() os.remove(filename)