{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {
    "Notes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The mode  is calculated using "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "numpy.unique",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": "numpy",
                "version": "*",
                "kind": "api",
                "path": "numpy:unique"
              },
              "kind": "module"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". In NumPy versions 1.21 and after, all NaNs - even those with different binary representations - are treated as equivalent and counted as separate instances of the same value."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "By convention, the mode of an empty array is NaN, and the associated count is zero."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Beginning in SciPy 1.9, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " inputs (not recommended for new code) are converted to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " before the calculation is performed. In this case, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of appropriate shape rather than a 2D "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.matrix"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Similarly, while masked elements of masked arrays are ignored, the output will be a scalar or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "np.ndarray"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " rather than a masked array with "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "mask=False"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Array API Standard Support"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "mode",
              "reference": {
                "__type": "RefInfo",
                "__tag": 4000,
                "module": null,
                "version": null,
                "kind": "local",
                "path": "mode"
              },
              "kind": "local"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "SCIPY_ARRAY_API=1"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "====================  ====================  ====================\nLibrary               CPU                   GPU\n====================  ====================  ====================\nNumPy                 ✅                     n/a                 \nCuPy                  n/a                   ⛔                   \nPyTorch               ✅                     ✅                   \nJAX                   ⛔                     ⛔                   \nDask                  ⛔                     n/a                 \n====================  ====================  ====================",
          "execution_status": null
        },
        {
          "__type": "Blockquote",
          "__tag": 4059,
          "children": [
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "See "
                },
                {
                  "__type": "InlineRole",
                  "__tag": 4003,
                  "value": "dev-arrayapi",
                  "domain": null,
                  "role": "ref",
                  "inventory": null
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " for more information."
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Raises": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Yields": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Methods": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Returns": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "mode",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of modal values."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "count",
              "annotation": "ndarray",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Array of counts for each mode."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Return an array of the modal (most common) value in the passed array."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Receives": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Warnings": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Attributes": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    },
    "Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Parameters",
          "__tag": 4026,
          "children": [
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "a",
              "annotation": "array_like",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Numeric, n-dimensional array of which to find mode(s)."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "axis",
              "annotation": "int or None, default: 0",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If an int, the axis of the input along which to compute the statistic. The statistic of each axis-slice (e.g. row) of the input will appear in a corresponding element of the output. If "
                    },
                    {
                      "__type": "InlineCode",
                      "__tag": 4051,
                      "value": "None"
                    },
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": ", the input will be raveled before computing the statistic."
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "nan_policy",
              "annotation": "{'propagate', 'omit', 'raise'}",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "Defines how to handle input NaNs."
                    }
                  ]
                },
                {
                  "__type": "BulletList",
                  "__tag": 4053,
                  "ordered": false,
                  "start": 1,
                  "children": [
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "propagate"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present in the axis slice (e.g. row) along   which the  statistic is computed, the corresponding entry of the output   will be NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "omit"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": NaNs will be omitted when performing the calculation.   If insufficient data remains in the axis slice along which the   statistic is computed, the corresponding entry of the output will be   NaN."
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "__type": "ListItem",
                      "__tag": 4054,
                      "children": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "raise"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": ": if a NaN is present, a "
                            },
                            {
                              "__type": "InlineCode",
                              "__tag": 4051,
                              "value": "ValueError"
                            },
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": " will be raised."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "DocParam",
              "__tag": 4016,
              "name": "keepdims",
              "annotation": "bool, default: False",
              "desc": [
                {
                  "__type": "Paragraph",
                  "__tag": 4045,
                  "children": [
                    {
                      "__type": "Text",
                      "__tag": 4046,
                      "value": "If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array."
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Extended Summary": {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "If there is more than one such value, only one is returned. The bin-count for the modal bins is also returned."
            }
          ]
        }
      ],
      "title": [],
      "level": 0,
      "target": null
    },
    "Other Parameters": {
      "__type": "Section",
      "__tag": 4015,
      "children": [],
      "title": [],
      "level": 0,
      "target": null
    }
  },
  "_ordered_sections": [
    "Summary",
    "Extended Summary",
    "Parameters",
    "Attributes",
    "Methods",
    "Returns",
    "Yields",
    "Receives",
    "Other Parameters",
    "Raises",
    "Warns",
    "Warnings",
    "Notes"
  ],
  "item_file": "/scipy/stats/_stats_py.py",
  "item_line": 482,
  "item_type": "function",
  "aliases": [
    "scipy.stats.mode"
  ],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "import numpy as np\na = np.array([[3, 0, 3, 7],\n              [3, 2, 6, 2],\n              [1, 7, 2, 8],\n              [3, 0, 6, 1],\n              [3, 2, 5, 5]])\nfrom scipy import stats\nstats.mode(a, keepdims=True)\n",
        "execution_status": "success"
      },
      {
        "__type": "Text",
        "__tag": 4046,
        "value": "\nTo get mode of whole array, specify ``axis=None``:\n\n"
      },
      {
        "__type": "Code",
        "__tag": 4050,
        "value": "stats.mode(a, axis=None, keepdims=True)\nstats.mode(a, axis=None, keepdims=False)\n",
        "execution_status": "failure"
      }
    ],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": {
    "__type": "SignatureNode",
    "__tag": 4029,
    "kind": "function",
    "parameters": [
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "a",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": {
          "__type": "Empty",
          "__tag": 4031
        }
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "axis",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "0"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "nan_policy",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "propagate"
      },
      {
        "__type": "SigParam",
        "__tag": 4030,
        "name": "keepdims",
        "annotation": {
          "__type": "Empty",
          "__tag": 4031
        },
        "kind": "POSITIONAL_OR_KEYWORD",
        "default": "False"
      }
    ],
    "return_annotation": {
      "__type": "Empty",
      "__tag": 4031
    },
    "target_name": "mode"
  },
  "references": null,
  "qa": "scipy.stats._stats_py:mode",
  "arbitrary": [],
  "local_refs": [
    "a",
    "axis",
    "count",
    "keepdims",
    "mode",
    "nan_policy"
  ]
}