class_docstr: DataFrame accessor for sparse data.
  
  Examples
  --------
  >>> df = pd.DataFrame({"a": [1, 2, 0, 0],
  ...                   "b": [3, 0, 0, 4]}, dtype="Sparse[int]")
  >>> df.sparse.density
  0.5
class_docstr_tok: ["DataFrame","accessor","for","sparse","data",".","Examples","--","--","--","--",">",">",">","df","=","pd.DataFrame","(","{","``","a","''",":","[","1",",","2",",","0",",","0","]",",","...","``","b","''",":","[","3",",","0",",","0",",","4","]","}",",","dtype=","''","Sparse","[","int","]","''",")",">",">",">","df.sparse.density","0.5"]
docstr: Return the contents of the frame as a sparse SciPy COO matrix.
  
  Returns
  -------
  scipy.sparse.spmatrix
      If the caller is heterogeneous and contains booleans or objects,
      the result will be of dtype=object. See Notes.
  
  Notes
  -----
  The dtype will be the lowest-common-denominator type (implicit
  upcasting); that is to say if the dtypes (even of numeric types)
  are mixed, the one that accommodates all will be chosen.
  
  e.g. If the dtypes are float16 and float32, dtype will be upcast to
  float32. By numpy.find_common_type convention, mixing int64 and
  and uint64 will result in a float64 dtype.
  
  Examples
  --------
  >>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})
  >>> df.sparse.to_coo()
  <4x1 sparse matrix of type '<class 'numpy.int64'>'
          with 2 stored elements in COOrdinate format>
docstr_tok: ["Return","the","contents","of","the","frame","as","a","sparse","SciPy","COO","matrix",".","Returns","--","--","--","-","scipy.sparse.spmatrix","If","the","caller","is","heterogeneous","and","contains","booleans","or","objects",",","the","result","will","be","of","dtype=object",".","See","Notes",".","Notes","--","--","-","The","dtype","will","be","the","lowest-common-denominator","type","(","implicit","upcasting",")",";","that","is","to","say","if","the","dtypes","(","even","of","numeric","types",")","are","mixed",",","the","one","that","accommodates","all","will","be","chosen",".","e.g",".","If","the","dtypes","are","float16","and","float32",",","dtype","will","be","upcast","to","float32",".","By","numpy.find_common_type","convention",",","mixing","int64","and","and","uint64","will","result","in","a","float64","dtype",".","Examples","--","--","--","--",">",">",">","df","=","pd.DataFrame","(","{","``","A","''",":","pd.arrays.SparseArray","(","[","0",",","1",",","0",",","1","]",")","}",")",">",">",">","df.sparse.to_coo","(",")","<","4x1","sparse","matrix","of","type","'","<","class","'numpy.int64","'",">","'","with","2","stored","elements","in","COOrdinate","format",">"]
code: def to_coo(self) -> spmatrix:
      """
      Return the contents of the frame as a sparse SciPy COO matrix.
  
      Returns
      -------
      scipy.sparse.spmatrix
          If the caller is heterogeneous and contains booleans or objects,
          the result will be of dtype=object. See Notes.
  
      Notes
      -----
      The dtype will be the lowest-common-denominator type (implicit
      upcasting); that is to say if the dtypes (even of numeric types)
      are mixed, the one that accommodates all will be chosen.
  
      e.g. If the dtypes are float16 and float32, dtype will be upcast to
      float32. By numpy.find_common_type convention, mixing int64 and
      and uint64 will result in a float64 dtype.
  
      Examples
      --------
      >>> df = pd.DataFrame({"A": pd.arrays.SparseArray([0, 1, 0, 1])})
      >>> df.sparse.to_coo()
      <4x1 sparse matrix of type '<class 'numpy.int64'>'
              with 2 stored elements in COOrdinate format>
      """
      import_optional_dependency("scipy")
      from scipy.sparse import coo_matrix
  
      dtype = find_common_type(self._parent.dtypes.to_list())
      if isinstance(dtype, SparseDtype):
          dtype = dtype.subtype
  
      cols, rows, data = [], [], []
      for col, (_, ser) in enumerate(self._parent.items()):
          sp_arr = ser.array
          if sp_arr.fill_value != 0:
              raise ValueError(
                  "fill value must be 0 when converting to COO matrix"
              )
  
          row = sp_arr.sp_index.indices
          cols.append(np.repeat(col, len(row)))
          rows.append(row)
          data.append(sp_arr.sp_values.astype(dtype, copy=False))
  
      cols = np.concatenate(cols)
      rows = np.concatenate(rows)
      data = np.concatenate(data)
      return coo_matrix((data, (rows, cols)), shape=self._parent.shape)
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING
  import numpy
  from pandas.compat._optional import import_optional_dependency
  from pandas.core.dtypes.cast import find_common_type
  from pandas.core.dtypes.dtypes import SparseDtype
  from pandas.core.accessor import PandasDelegate, delegate_names
  from pandas.core.arrays.sparse.array import SparseArray
label_desc: Use image node_id 4 for calling the SparseFrameAccessor obj's underlying member method code with example usage: obj.to_coo() and returns: coo_matrix