Repository: pandas-dev/pandas
Pull request #58218 (2024-04-11 12:24:43)

Revert "CI: Pin blosc to fix pytables"
Reverts pandas-dev/pandas#58209


Patch:
diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml
index 7402f6495c..ed7dfe1a3c 100644
--- a/ci/deps/actions-310.yaml
+++ b/ci/deps/actions-310.yaml
@@ -24,8 +24,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/ci/deps/actions-311-downstream_compat.yaml b/ci/deps/actions-311-downstream_compat.yaml
index 15ff3d6dbe..dd1d341c70 100644
--- a/ci/deps/actions-311-downstream_compat.yaml
+++ b/ci/deps/actions-311-downstream_compat.yaml
@@ -26,8 +26,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/ci/deps/actions-311.yaml b/ci/deps/actions-311.yaml
index 586cf26da7..388116439f 100644
--- a/ci/deps/actions-311.yaml
+++ b/ci/deps/actions-311.yaml
@@ -24,8 +24,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/ci/deps/actions-312.yaml b/ci/deps/actions-312.yaml
index 96abc7744d..1d9f8aa3b0 100644
--- a/ci/deps/actions-312.yaml
+++ b/ci/deps/actions-312.yaml
@@ -24,8 +24,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/ci/deps/actions-39-minimum_versions.yaml b/ci/deps/actions-39-minimum_versions.yaml
index 4756f10460..b760f27a3d 100644
--- a/ci/deps/actions-39-minimum_versions.yaml
+++ b/ci/deps/actions-39-minimum_versions.yaml
@@ -27,8 +27,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc=1.21.3
   - bottleneck=1.3.6
   - fastparquet=2023.10.0
diff --git a/ci/deps/actions-39.yaml b/ci/deps/actions-39.yaml
index 8154486ff5..8f235a836b 100644
--- a/ci/deps/actions-39.yaml
+++ b/ci/deps/actions-39.yaml
@@ -24,8 +24,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/ci/deps/circle-310-arm64.yaml b/ci/deps/circle-310-arm64.yaml
index dc6adf1757..ed4d139714 100644
--- a/ci/deps/circle-310-arm64.yaml
+++ b/ci/deps/circle-310-arm64.yaml
@@ -25,8 +25,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc>=1.21.3
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst
index 66c209efb7..269f6e1a96 100644
--- a/doc/source/whatsnew/v3.0.0.rst
+++ b/doc/source/whatsnew/v3.0.0.rst
@@ -36,7 +36,7 @@ Other enhancements
 - Support reading value labels from Stata 108-format (Stata 6) and earlier files (:issue:`58154`)
 - Users can globally disable any ``PerformanceWarning`` by setting the option ``mode.performance_warnings`` to ``False`` (:issue:`56920`)
 - :meth:`Styler.format_index_names` can now be used to format the index and column names (:issue:`48936` and :issue:`47489`)
--
+- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
 
 .. ---------------------------------------------------------------------------
 .. _whatsnew_300.notable_bug_fixes:
diff --git a/environment.yml b/environment.yml
index ac4bd05684..186d7e1d70 100644
--- a/environment.yml
+++ b/environment.yml
@@ -28,8 +28,6 @@ dependencies:
 
   # optional dependencies
   - beautifulsoup4>=4.11.2
-  # https://github.com/conda-forge/pytables-feedstock/issues/97
-  - c-blosc2=2.13.2
   - blosc
   - bottleneck>=1.3.6
   - fastparquet>=2023.10.0
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
index 76df5c82e6..6db1811a98 100644
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -12043,20 +12043,52 @@ class DataFrame(NDFrame, OpsMixin):
     product = prod
 
     @doc(make_doc("cummin", ndim=2))
-    def cummin(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Self:
-        return NDFrame.cummin(self, axis, skipna, *args, **kwargs)
+    def cummin(
+        self,
+        axis: Axis = 0,
+        skipna: bool = True,
+        numeric_only: bool = False,
+        *args,
+        **kwargs,
+    ) -> Self:
+        data = self._get_numeric_data() if numeric_only else self
+        return NDFrame.cummin(data, axis, skipna, *args, **kwargs)
 
     @doc(make_doc("cummax", ndim=2))
-    def cummax(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Self:
-        return NDFrame.cummax(self, axis, skipna, *args, **kwargs)
+    def cummax(
+        self,
+        axis: Axis = 0,
+        skipna: bool = True,
+        numeric_only: bool = False,
+        *args,
+        **kwargs,
+    ) -> Self:
+        data = self._get_numeric_data() if numeric_only else self
+        return NDFrame.cummax(data, axis, skipna, *args, **kwargs)
 
     @doc(make_doc("cumsum", ndim=2))
-    def cumsum(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Self:
-        return NDFrame.cumsum(self, axis, skipna, *args, **kwargs)
+    def cumsum(
+        self,
+        axis: Axis = 0,
+        skipna: bool = True,
+        numeric_only: bool = False,
+        *args,
+        **kwargs,
+    ) -> Self:
+        data = self._get_numeric_data() if numeric_only else self
+        return NDFrame.cumsum(data, axis, skipna, *args, **kwargs)
 
     @doc(make_doc("cumprod", 2))
-    def cumprod(self, axis: Axis = 0, skipna: bool = True, *args, **kwargs) -> Self:
-        return NDFrame.cumprod(self, axis, skipna, *args, **kwargs)
+    def cumprod(
+        self,
+        axis: Axis = 0,
+        skipna: bool = True,
+        numeric_only: bool = False,
+        *args,
+        **kwargs,
+    ) -> Self:
+        data = self._get_numeric_data() if numeric_only else self
+        return NDFrame.cumprod(data, axis, skipna, *args, **kwargs)
 
     def nunique(self, axis: Axis = 0, dropna: bool = True) -> Series:
         """
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 8af9503a36..e1c1b21249 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -11925,7 +11925,45 @@ Series.all : Return True if all elements are True.
 DataFrame.any : Return True if one (or more) elements are True.
 """
 
-_cnum_doc = """
+_cnum_pd_doc = """
+Return cumulative {desc} over a DataFrame or Series axis.
+
+Returns a DataFrame or Series of the same size containing the cumulative
+{desc}.
+
+Parameters
+----------
+axis : {{0 or 'index', 1 or 'columns'}}, default 0
+    The index or the name of the axis. 0 is equivalent to None or 'index'.
+    For `Series` this parameter is unused and defaults to 0.
+skipna : bool, default True
+    Exclude NA/null values. If an entire row/column is NA, the result
+    will be NA.
+numeric_only : bool, default False
+    Include only float, int, boolean columns.
+*args, **kwargs
+    Additional keywords have no effect but might be accepted for
+    compatibility with NumPy.
+
+Returns
+-------
+{name1} or {name2}
+    Return cumulative {desc} of {name1} or {name2}.
+
+See Also
+--------
+core.window.expanding.Expanding.{accum_func_name} : Similar functionality
+    but ignores ``NaN`` values.
+{name2}.{accum_func_name} : Return the {desc} over
+    {name2} axis.
+{name2}.cummax : Return cumulative maximum over {name2} axis.
+{name2}.cummin : Return cumulative minimum over {name2} axis.
+{name2}.cumsum : Return cumulative sum over {name2} axis.
+{name2}.cumprod : Return cumulative product over {name2} axis.
+
+{examples}"""
+
+_cnum_series_doc = """
 Return cumulative {desc} over a DataFrame or Series axis.
 
 Returns a DataFrame or Series of the same size containing the cumulative
@@ -12716,28 +12754,44 @@ def make_doc(name: str, ndim: int) -> str:
         kwargs = {"min_count": ""}
 
     elif name == "cumsum":
-        base_doc = _cnum_doc
+        if ndim == 1:
+            base_doc = _cnum_series_doc
+        else:
+            base_doc = _cnum_pd_doc
+
         desc = "sum"
         see_also = ""
         examples = _cumsum_examples
         kwargs = {"accum_func_name": "sum"}
 
     elif name == "cumprod":
-        base_doc = _cnum_doc
+        if ndim == 1:
+            base_doc = _cnum_series_doc
+        else:
+            base_doc = _cnum_pd_doc
+
         desc = "product"
         see_also = ""
         examples = _cumprod_examples
         kwargs = {"accum_func_name": "prod"}
 
     elif name == "cummin":
-        base_doc = _cnum_doc
+        if ndim == 1:
+            base_doc = _cnum_series_doc
+        else:
+            base_doc = _cnum_pd_doc
+
         desc = "minimum"
         see_also = ""
         examples = _cummin_examples
         kwargs = {"accum_func_name": "min"}
 
     elif name == "cummax":
-        base_doc = _cnum_doc
+        if ndim == 1:
+            base_doc = _cnum_series_doc
+        else:
+            base_doc = _cnum_pd_doc
+
         desc = "maximum"
         see_also = ""
         examples = _cummax_examples
diff --git a/scripts/generate_pip_deps_from_conda.py b/scripts/generate_pip_deps_from_conda.py
index 4e4e54c5be..d54d35bc01 100755
--- a/scripts/generate_pip_deps_from_conda.py
+++ b/scripts/generate_pip_deps_from_conda.py
@@ -23,7 +23,7 @@ else:
     import tomli as tomllib
 import yaml
 
-EXCLUDE = {"python", "c-compiler", "cxx-compiler", "c-blosc2"}
+EXCLUDE = {"python", "c-compiler", "cxx-compiler"}
 REMAP_VERSION = {"tzdata": "2022.7"}
 CONDA_TO_PIP = {
     "pytables": "tables",
diff --git a/scripts/validate_min_versions_in_sync.py b/scripts/validate_min_versions_in_sync.py
index 59989aadf7..1001b00450 100755
--- a/scripts/validate_min_versions_in_sync.py
+++ b/scripts/validate_min_versions_in_sync.py
@@ -36,7 +36,7 @@ CODE_PATH = pathlib.Path("pandas/compat/_optional.py").resolve()
 SETUP_PATH = pathlib.Path("pyproject.toml").resolve()
 YAML_PATH = pathlib.Path("ci/deps")
 ENV_PATH = pathlib.Path("environment.yml")
-EXCLUDE_DEPS = {"tzdata", "blosc", "c-blosc2", "pyqt", "pyqt5"}
+EXCLUDE_DEPS = {"tzdata", "blosc", "pyqt", "pyqt5"}
 EXCLUSION_LIST = frozenset(["python=3.8[build=*_pypy]"])
 # pandas package is not available
 # in pre-commit environment
@@ -225,9 +225,6 @@ def get_versions_from_ci(content: list[str]) -> tuple[dict[str, str], dict[str,
             seen_required = True
         elif "# optional dependencies" in line:
             seen_optional = True
-        elif "#" in line:
-            # just a comment
-            continue
         elif "- pip:" in line:
             continue
         elif seen_required and line.strip():


Test patch:
diff --git a/pandas/tests/frame/test_cumulative.py b/pandas/tests/frame/test_cumulative.py
index d7aad680d3..ab217e1b13 100644
--- a/pandas/tests/frame/test_cumulative.py
+++ b/pandas/tests/frame/test_cumulative.py
@@ -7,10 +7,12 @@ tests.series.test_cumulative
 """
 
 import numpy as np
+import pytest
 
 from pandas import (
     DataFrame,
     Series,
+    Timestamp,
 )
 import pandas._testing as tm
 
@@ -81,3 +83,25 @@ class TestDataFrameCumulativeOps:
             }
         )
         tm.assert_frame_equal(result, expected)
+
+    @pytest.mark.parametrize("method", ["cumsum", "cumprod", "cummin", "cummax"])
+    @pytest.mark.parametrize("axis", [0, 1])
+    def test_numeric_only_flag(self, method, axis):
+        df = DataFrame(
+            {
+                "int": [1, 2, 3],
+                "bool": [True, False, False],
+                "string": ["a", "b", "c"],
+                "float": [1.0, 3.5, 4.0],
+                "datetime": [
+                    Timestamp(2018, 1, 1),
+                    Timestamp(2019, 1, 1),
+                    Timestamp(2020, 1, 1),
+                ],
+            }
+        )
+        df_numeric_only = df.drop(["string", "datetime"], axis=1)
+
+        result = getattr(df, method)(axis=axis, numeric_only=True)
+        expected = getattr(df_numeric_only, method)(axis)
+        tm.assert_frame_equal(result, expected)
diff --git a/pandas/tests/groupby/test_api.py b/pandas/tests/groupby/test_api.py
index b5fdf058d1..d2cfa530e7 100644
--- a/pandas/tests/groupby/test_api.py
+++ b/pandas/tests/groupby/test_api.py
@@ -183,10 +183,9 @@ def test_frame_consistency(groupby_func):
     elif groupby_func in ("bfill", "ffill"):
         exclude_expected = {"inplace", "axis", "limit_area"}
     elif groupby_func in ("cummax", "cummin"):
-        exclude_expected = {"skipna", "args"}
-        exclude_result = {"numeric_only"}
+        exclude_expected = {"axis", "skipna", "args"}
     elif groupby_func in ("cumprod", "cumsum"):
-        exclude_expected = {"skipna"}
+        exclude_expected = {"axis", "skipna", "numeric_only"}
     elif groupby_func in ("pct_change",):
         exclude_expected = {"kwargs"}
     elif groupby_func in ("rank",):