{"record":{"id":"88c29af1c6c45089","repo":"pandas-dev/pandas","slug":"how-with-perioddtype-is-no-longer-supported-u","errorCode":null,"errorMessage":"'{how}' with PeriodDtype is no longer supported. Use (obj != pd.Period(ordinal=0, freq=freq)).{how}() instead.","messagePattern":"'(.+?)' with PeriodDtype is no longer supported\\. Use \\(obj != pd\\.Period\\(ordinal=0, freq=freq\\)\\)\\.(.+?)\\(\\) instead\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/datetimelike.py","lineNumber":1647,"sourceCode":"        dtype = self.dtype\n        if dtype.kind == \"M\":\n            # Adding/multiplying datetimes is not valid\n            if how in [\"sum\", \"prod\", \"cumsum\", \"cumprod\", \"var\", \"skew\", \"kurt\"]:\n                raise TypeError(f\"datetime64 type does not support operation '{how}'\")\n            if how in [\"any\", \"all\"]:\n                # GH#34479\n                raise TypeError(\n                    f\"'{how}' with datetime64 dtypes is no longer supported. \"\n                    f\"Use (obj != pd.Timestamp(0)).{how}() instead.\"\n                )\n\n        elif isinstance(dtype, PeriodDtype):\n            # Adding/multiplying Periods is not valid\n            if how in [\"sum\", \"prod\", \"cumsum\", \"cumprod\", \"var\", \"skew\", \"kurt\"]:\n                raise TypeError(f\"Period type does not support {how} operations\")\n            if how in [\"any\", \"all\"]:\n                # GH#34479\n                raise TypeError(\n                    f\"'{how}' with PeriodDtype is no longer supported. \"\n                    f\"Use (obj != pd.Period(ordinal=0, freq=freq)).{how}() instead.\"\n                )\n        # timedeltas we can add but not multiply\n        elif how in [\"prod\", \"cumprod\", \"skew\", \"kurt\", \"var\"]:\n            raise TypeError(f\"timedelta64 type does not support {how} operations\")\n\n        # All of the functions implemented here are ordinal, so we can\n        #  operate on the tz-naive equivalents\n        npvalues = self._ndarray.view(\"M8[ns]\")\n\n        from pandas.core.groupby.ops import WrappedCythonOp\n\n        kind = WrappedCythonOp.get_kind_from_how(how)\n        op = WrappedCythonOp(how=how, kind=kind, has_dropped_na=has_dropped_na)\n\n        res_values = op._cython_op_ndim_compat(\n            npvalues,","sourceCodeStart":1629,"sourceCodeEnd":1665,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/datetimelike.py#L1629-L1665","documentation":"Raised in _groupby_op for PeriodDtype when how is 'any' or 'all' (GH#34479). Prior to the fix these fell through to a numeric path; the message now redirects users to a boolean test against a zero-ordinal Period, because 'any'/'all' over Periods are conceptually truthiness checks, not reductions the groupby engine should perform directly.","triggerScenarios":"groupby(...).any() or .all() on a Series/Index with PeriodDtype; the same call routed through resample/rolling when the underlying values are Periods.","commonSituations":"Reusing a generic 'are there any non-empty values' reduction (.any()) on a Period column after a schema change; pipelines that call .any()/.all() polymorphically across mixed-dtype columns; pandas 1.1+ migrations where old behavior quietly succeeded.","solutions":["Replace s.groupby(g).any() with (s != pd.Period(ordinal=0, freq=s.dtype.freq)).groupby(g).any().","If you only need 'are there non-NaT values', use s.notna().groupby(g).any() instead.","Drop the Period dtype before the call if the truthiness semantics are not what you want."],"exampleFix":"// before\ns = pd.Series(pd.PeriodIndex(['2020-01','2020-02',None], freq='M'))\ns.groupby([0,0,0]).any()  # TypeError: 'any' with PeriodDtype is no longer supported\n\n// after\n(s != pd.Period(ordinal=0, freq='M')).groupby([0,0,0]).any()","handlingStrategy":"validation","validationCode":"def period_any(s, group):\n    if isinstance(s.dtype, pd.PeriodDtype):\n        return (s != pd.Period(ordinal=0, freq=s.dtype.freq)).groupby(group).any()\n    return s.groupby(group).any()","typeGuard":"def needs_period_any_redirect(dtype, how) -> bool:\n    return isinstance(dtype, pd.PeriodDtype) and how in {\"any\",\"all\"}","tryCatchPattern":"try:\n    out = s.groupby(g).any()\nexcept TypeError as e:\n    if \"PeriodDtype is no longer supported\" in str(e):\n        out = (s != pd.Period(ordinal=0, freq=s.dtype.freq)).groupby(g).any()\n    else:\n        raise","preventionTips":["Prefer .notna().groupby(g).any() when you only need 'has non-null value'.","Lint for .any()/.all() calls on Period-typed columns.","Pin the GH#34479 workaround behind a dtype check in shared util code."],"tags":["pandas","period","groupby","any-all","gh34479"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}