docstr: Convert this array/matrix to Compressed Sparse Row format
  
  Duplicate entries will be summed together.
  
  Examples
  --------
  >>> from numpy import array
  >>> from scipy.sparse import coo_array
  >>> row  = array([0, 0, 1, 3, 1, 0, 0])
  >>> col  = array([0, 2, 1, 3, 1, 0, 0])
  >>> data = array([1, 1, 1, 1, 1, 1, 1])
  >>> A = coo_array((data, (row, col)), shape=(4, 4)).tocsr()
  >>> A.toarray()
  array([[3, 0, 1, 0],
         [0, 2, 0, 0],
         [0, 0, 0, 0],
         [0, 0, 0, 1]])
docstr_tok: ["Convert","this","array\/matrix","to","Compressed","Sparse","Row","format","Duplicate","entries","will","be","summed","together",".","Examples","--","--","--","--",">",">",">","from","numpy","import","array",">",">",">","from","scipy.sparse","import","coo_array",">",">",">","row","=","array","(","[","0",",","0",",","1",",","3",",","1",",","0",",","0","]",")",">",">",">","col","=","array","(","[","0",",","2",",","1",",","3",",","1",",","0",",","0","]",")",">",">",">","data","=","array","(","[","1",",","1",",","1",",","1",",","1",",","1",",","1","]",")",">",">",">","A","=","coo_array","(","(","data",",","(","row",",","col",")",")",",","shape=","(","4",",","4",")",")",".tocsr","(",")",">",">",">","A.toarray","(",")","array","(","[","[","3",",","0",",","1",",","0","]",",","[","0",",","2",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","1","]","]",")"]
code: def tocsr(self, copy=False):
      """Convert this array/matrix to Compressed Sparse Row format
  
      Duplicate entries will be summed together.
  
      Examples
      --------
      >>> from numpy import array
      >>> from scipy.sparse import coo_array
      >>> row  = array([0, 0, 1, 3, 1, 0, 0])
      >>> col  = array([0, 2, 1, 3, 1, 0, 0])
      >>> data = array([1, 1, 1, 1, 1, 1, 1])
      >>> A = coo_array((data, (row, col)), shape=(4, 4)).tocsr()
      >>> A.toarray()
      array([[3, 0, 1, 0],
             [0, 2, 0, 0],
             [0, 0, 0, 0],
             [0, 0, 0, 1]])
  
      """
      if self.ndim != 2:
          raise ValueError(
              "Cannot convert a 1d sparse array to csr format"
          )
      if self.nnz == 0:
          return self._csr_container(self.shape, dtype=self.dtype)
      else:
          M, N = self.shape
          idx_dtype = self._get_index_dtype(
              (self.row, self.col), maxval=max(self.nnz, N)
          )
          row = self.row.astype(idx_dtype, copy=False)
          col = self.col.astype(idx_dtype, copy=False)
  
          indptr = np.empty(M + 1, dtype=idx_dtype)
          indices = np.empty_like(col, dtype=idx_dtype)
          data = np.empty_like(self.data, dtype=upcast(self.dtype))
  
          coo_tocsr(
              M, N, self.nnz, row, col, self.data, indptr, indices, data
          )
  
          x = self._csr_container(
              (data, indices, indptr), shape=self.shape
          )
          if not self.has_canonical_format:
              x.sum_duplicates()
          return x
  
imports: import math
  from warnings import warn
  import numpy
  from ._matrix import spmatrix
  from ._sparsetools import coo_tocsr, coo_todense, coo_matvec
  from ._base import issparse, SparseEfficiencyWarning, _spbase, sparray
  from ._data import _data_matrix, _minmax_mixin
  from ._sputils import upcast, upcast_char, to_native, isshape, getdtype, getdata, downcast_intp_index, get_index_dtype, check_shape, check_reshape_kwargs
  import operator
label_desc: Use image node_id 13 for calling the _coo_base obj's underlying member method code with example usage: obj.tocsr(copy) and returns: self, x