From 54b98b7a68c974c410b881d4eeb94a6eac4695ea Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sun, 5 Sep 2021 22:39:17 +0200 Subject: [PATCH 1/6] add jinja2 hard dep --- ci/deps/actions-38-db-min.yaml | 1 + ci/deps/actions-38-db.yaml | 1 + ci/deps/actions-38-locale_slow.yaml | 1 + ci/deps/actions-38-slow.yaml | 1 + ci/deps/actions-38.yaml | 1 + ci/deps/actions-39-numpydev.yaml | 1 + environment.yml | 2 +- requirements-dev.txt | 2 +- setup.cfg | 1 + 9 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/deps/actions-38-db-min.yaml b/ci/deps/actions-38-db-min.yaml index c93f791b7dba7..55489a41f7997 100644 --- a/ci/deps/actions-38-db-min.yaml +++ b/ci/deps/actions-38-db-min.yaml @@ -15,6 +15,7 @@ dependencies: - numpy<1.20 # GH#39541 compat for pyarrow<3 - python-dateutil - pytz + - jinja2 # optional - beautifulsoup4 diff --git a/ci/deps/actions-38-db.yaml b/ci/deps/actions-38-db.yaml index b4495fa6887f4..d6c37cf62dad8 100644 --- a/ci/deps/actions-38-db.yaml +++ b/ci/deps/actions-38-db.yaml @@ -20,6 +20,7 @@ dependencies: - gcsfs>=0.6.0 - geopandas - html5lib + - jinja2 - matplotlib - moto>=1.3.14 - flask diff --git a/ci/deps/actions-38-locale_slow.yaml b/ci/deps/actions-38-locale_slow.yaml index e7276027f2a41..b55cc935e131d 100644 --- a/ci/deps/actions-38-locale_slow.yaml +++ b/ci/deps/actions-38-locale_slow.yaml @@ -28,3 +28,4 @@ dependencies: - xlsxwriter=1.2.2 - xlwt=1.3.0 - html5lib=1.1 + - jinja2 diff --git a/ci/deps/actions-38-slow.yaml b/ci/deps/actions-38-slow.yaml index 08900a31fe27c..39fe7ea7b086a 100644 --- a/ci/deps/actions-38-slow.yaml +++ b/ci/deps/actions-38-slow.yaml @@ -36,3 +36,4 @@ dependencies: - moto - flask - numba + - jinja2 diff --git a/ci/deps/actions-38.yaml b/ci/deps/actions-38.yaml index 86b038ff7d4b6..273d9e2d016ae 100644 --- a/ci/deps/actions-38.yaml +++ b/ci/deps/actions-38.yaml @@ -18,3 +18,4 @@ dependencies: - nomkl - pytz - tabulate==0.8.7 + - jinja2 diff --git a/ci/deps/actions-39-numpydev.yaml b/ci/deps/actions-39-numpydev.yaml index 03181a9d71d1d..18fe197eb0a24 100644 --- a/ci/deps/actions-39-numpydev.yaml +++ b/ci/deps/actions-39-numpydev.yaml @@ -13,6 +13,7 @@ dependencies: # pandas dependencies - python-dateutil - pytz + - jinja2 - pip - pip: - cython==0.29.21 # GH#34014 diff --git a/environment.yml b/environment.yml index 733bd06fbe12f..2199dd690d828 100644 --- a/environment.yml +++ b/environment.yml @@ -7,6 +7,7 @@ dependencies: - python=3.8 - python-dateutil>=2.8.1 - pytz + - jinja2 # pandas.Styler (DataFrame.to_html / to_latex) # benchmarks - asv @@ -79,7 +80,6 @@ dependencies: - bottleneck>=1.3.1 - ipykernel - ipython>=7.11.1 - - jinja2 # pandas.Styler - matplotlib>=3.3.2 # pandas.plotting, Series.plot, DataFrame.plot - numexpr>=2.7.1 - scipy>=1.4.1 diff --git a/requirements-dev.txt b/requirements-dev.txt index 9b35de4bccb48..218bf15865064 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,6 +4,7 @@ numpy>=1.18.5 python-dateutil>=2.8.1 pytz +jinja2 asv cython>=0.29.21 black==21.5b2 @@ -51,7 +52,6 @@ blosc bottleneck>=1.3.1 ipykernel ipython>=7.11.1 -jinja2 matplotlib>=3.3.2 numexpr>=2.7.1 scipy>=1.4.1 diff --git a/setup.cfg b/setup.cfg index 62ff0c6934f77..dcd2d3e4d2128 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,6 +33,7 @@ install_requires = numpy>=1.18.5 python-dateutil>=2.8.1 pytz>=2020.1 + jinja2>=2.11 python_requires = >=3.8 include_package_data = True zip_safe = False From 0f0eb84430cc5578ae07b455a1a22fd979713b0a Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sun, 5 Sep 2021 22:49:14 +0200 Subject: [PATCH 2/6] edit docs --- doc/source/getting_started/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index 20ae37c85a9d9..e94609ec48550 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -227,6 +227,7 @@ Package Minimum support `NumPy `__ 1.18.5 `python-dateutil `__ 2.8.1 `pytz `__ 2020.1 +`jinja2 `__ 2.11 ================================================================ ========================== .. _install.recommended_dependencies: @@ -266,7 +267,6 @@ Visualization Dependency Minimum Version Notes ========================= ================== ============================================================= matplotlib 3.3.2 Plotting library -Jinja2 2.11 Conditional formatting with DataFrame.style tabulate 0.8.7 Printing in Markdown-friendly format (see `tabulate`_) ========================= ================== ============================================================= From 4c4ba6d1f2a58b73e17cfd5462d9d8c39018a530 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Sun, 5 Sep 2021 22:50:05 +0200 Subject: [PATCH 3/6] edit docs --- doc/source/getting_started/install.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index e94609ec48550..99b96b62e314e 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -227,7 +227,7 @@ Package Minimum support `NumPy `__ 1.18.5 `python-dateutil `__ 2.8.1 `pytz `__ 2020.1 -`jinja2 `__ 2.11 +`Jinja2 `__ 2.11 ================================================================ ========================== .. _install.recommended_dependencies: From 013e44784b6daeb4395179ad92d9a4552fdfec20 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Mon, 6 Sep 2021 18:19:37 +0200 Subject: [PATCH 4/6] fix tests by avoiding numpy ambiguous --- pandas/io/formats/style.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 616e533bdc10f..76f859573f5e9 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -2193,7 +2193,7 @@ def hide_index( hrows = self.index.get_indexer_for(hide.index) # error: Incompatible types in assignment (expression has type # "ndarray", variable has type "Sequence[int]") - self.hidden_rows = hrows # type: ignore[assignment] + self.hidden_rows = list(hrows) # type: ignore[assignment] if names: self.hide_index_names = True @@ -2332,7 +2332,7 @@ def hide_columns( hcols = self.columns.get_indexer_for(hide.columns) # error: Incompatible types in assignment (expression has type # "ndarray", variable has type "Sequence[int]") - self.hidden_columns = hcols # type: ignore[assignment] + self.hidden_columns = list(hcols) # type: ignore[assignment] if names: self.hide_column_names = True From af3d210779bde54b6211a232ededda464ce3c84a Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Mon, 6 Sep 2021 23:48:18 +0200 Subject: [PATCH 5/6] mypy fix --- pandas/io/formats/style.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 76f859573f5e9..13424362a8fbc 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -2191,9 +2191,7 @@ def hide_index( subset = non_reducing_slice(subset_) hide = self.data.loc[subset] hrows = self.index.get_indexer_for(hide.index) - # error: Incompatible types in assignment (expression has type - # "ndarray", variable has type "Sequence[int]") - self.hidden_rows = list(hrows) # type: ignore[assignment] + self.hidden_rows = list(hrows) if names: self.hide_index_names = True @@ -2330,9 +2328,7 @@ def hide_columns( subset = non_reducing_slice(subset_) hide = self.data.loc[subset] hcols = self.columns.get_indexer_for(hide.columns) - # error: Incompatible types in assignment (expression has type - # "ndarray", variable has type "Sequence[int]") - self.hidden_columns = list(hcols) # type: ignore[assignment] + self.hidden_columns = list(hcols) if names: self.hide_column_names = True From fd24d9441dedb401aff4361ef7b501964dd6bd81 Mon Sep 17 00:00:00 2001 From: "JHM Darbyshire (iMac)" Date: Tue, 7 Sep 2021 17:38:09 +0200 Subject: [PATCH 6/6] Merge remote-tracking branch 'upstream/master' into latex_multicol_naive # Conflicts: # pandas/io/formats/style.py # pandas/tests/io/formats/style/test_to_latex.py --- doc/source/whatsnew/v1.4.0.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index bb9c124bae68b..663c1fb45d7ba 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -218,6 +218,10 @@ Optional libraries below the lowest tested version may still work, but are not c See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more. +Also note that ``Jinja2``, with minimum version 2.11, has been made a hard dependency to support +DataFrame rendering in LaTeX and HTML formats, where the methods :meth:`DataFrame.to_latex` and +:meth:`DataFrame.to_html` now utilise the :class:`.Styler` template parsing mechanics. + .. _whatsnew_140.api_breaking.other: Other API changes