{"record":{"id":"04e3c986b2b90968","repo":"pandas-dev/pandas","slug":"axis-other-than-0-is-not-supported","errorCode":null,"errorMessage":"axis other than 0 is not supported","messagePattern":"axis other than 0 is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/apply.py","lineNumber":882,"sourceCode":"\n    def agg_or_apply_list_like(\n        self, op_name: Literal[\"agg\", \"apply\"]\n    ) -> DataFrame | Series:\n        obj = self.obj\n        kwargs = self.kwargs\n\n        if op_name == \"apply\":\n            if isinstance(self, FrameApply):\n                by_row = self.by_row\n\n            elif isinstance(self, SeriesApply):\n                by_row = \"_compat\" if self.by_row else False\n            else:\n                by_row = False\n            kwargs = {**kwargs, \"by_row\": by_row}\n\n        if getattr(obj, \"axis\", 0) == 1:\n            raise NotImplementedError(\"axis other than 0 is not supported\")\n\n        if op_name == \"agg\" and isinstance(self, FrameApply):\n            result = self._agg_list_like_frame_reductions()\n            if result is not None:\n                return result\n\n        keys, results = self.compute_list_like(op_name, obj, kwargs)\n        result = self.wrap_results_list_like(keys, results)\n        return result\n\n    def agg_or_apply_dict_like(\n        self, op_name: Literal[\"agg\", \"apply\"]\n    ) -> DataFrame | Series:\n        assert op_name in [\"agg\", \"apply\"]\n        obj = self.obj\n\n        kwargs = {}\n        if op_name == \"apply\":","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/apply.py#L864-L900","documentation":"Raised in `agg_or_apply_list_like` when the object's axis attribute is 1 (column-wise operation) for a list-like agg/apply path that only supports axis=0. List-like aggregation iterates columns, so the implementation deliberately rejects axis=1 to avoid surprising behavior.","triggerScenarios":"`df.agg(['sum', 'mean'], axis=1)` — list-like func with axis=1. The check at apply.py:881 (`getattr(obj, 'axis', 0) == 1`) fires.","commonSituations":"Copy-pasting axis=1 from a single-function apply call into a list-based agg; assuming axis symmetry across all agg surfaces; refactoring from row-wise apply to list-agg without dropping axis.","solutions":["Drop axis=1 and let agg operate column-wise (axis=0), which is the only supported direction for list-like func.","Transpose the frame: `df.T.agg(['sum', 'mean']).T` if you genuinely need row-wise reduction.","Use `df.apply(func, axis=1)` with a single function that internally computes multiple stats, returning a Series."],"exampleFix":"# before\ndf.agg(['sum', 'mean'], axis=1)\n# after\ndf.T.agg(['sum', 'mean']).T","handlingStrategy":"validation","validationCode":"def safe_list_agg(df, funcs, axis=0):\n    if axis == 1:\n        raise NotImplementedError('list-like agg supports axis=0 only; use df.T')\n    return df.agg(funcs, axis=axis)","typeGuard":"def is_axis0_or_transposable(axis) -> bool:\n    return axis == 0","tryCatchPattern":"try:\n    df.agg(funcs, axis=1)\nexcept NotImplementedError as e:\n    if 'axis other than 0' in str(e):\n        df.T.agg(funcs).T\n    else:\n        raise","preventionTips":["Do not pass axis=1 with list-like agg; transpose the frame instead.","Keep a helper for row-wise multi-stat reduction."],"tags":["pandas","agg","apply","axis","notimplementederror","list-like"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}