{"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/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/apply.py#L864-L900","documentation":"Raised as NotImplementedError at the top of `agg_or_apply_list_like` when the target object's `axis` attribute equals 1. List-like agg/apply in pandas is only implemented for axis=0 (column-wise); requesting axis=1 (row-wise) on a list/dict of functions is not supported, so pandas fails fast.","triggerScenarios":"`df.agg(['mean', 'sum'], axis=1)`, `df.apply([f1, f2], axis=1)`, or any list-like agg/apply routed through this method with `obj.axis == 1`.","commonSituations":"Developers assume symmetry: `df.mean(axis=1)` works, so `df.agg([...], axis=1)` should too. Or they reuse a column-wise agg spec on a transposed frame.","solutions":["Transpose first: `df.T.agg([...]).T`, performing the list-agg column-wise on the transpose.","Use a row-wise callable with `df.apply(func, axis=1)` instead of a list of aggregators.","Compute each aggregator separately with `axis=1` and concatenate: `pd.concat([df.agg(f, axis=1) for f in funcs], axis=1)`."],"exampleFix":"// before\ndf.agg(['mean', 'sum'], axis=1)\n// after\ndf.T.agg(['mean', 'sum']).T","handlingStrategy":"validation","validationCode":"def list_agg_axis_safe(df, funcs, axis=0):\n    if axis == 1:\n        return df.T.agg(funcs).T\n    return df.agg(funcs, axis=axis)","typeGuard":"def list_agg_axis_supported(axis) -> bool:\n    return axis == 0","tryCatchPattern":"try:\n    out = df.agg(funcs, axis=1)\nexcept NotImplementedError as e:\n    if 'axis other than 0' in str(e):\n        out = df.T.agg(funcs).T\n    else:\n        raise","preventionTips":["Remember list/dict agg is column-wise only.","Transpose first when you genuinely need row-wise list-agg.","Document the axis=0 constraint in helper functions."],"tags":["pandas","agg","apply","axis","notimplementederror"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}