title: scipy sparse A[:,0] = ndarray ValueError
body: <p>Setting the first row of a scipy sparse array <code>A[0,:] = np.ones()</code> works fine, <br />
  but trying to set the first column with <code>A[:,0] = np.ones()</code> raises a ValueError. <br />
  Is this a bug in scipy 1.5.2, or have I not found doc which describes this ?</p>
  <p>Answer 13 sep: this is a known bug area, see <a href="https://github.com/scipy/scipy/issues/10695" rel="nofollow noreferrer">issues/10695</a>
  and the newest <a href="https://github.com/scipy/scipy/blob/master/scipy/sparse/_index.py" rel="nofollow noreferrer">scipy/sparse/_index.py</a>.
  However I have not tested <code>A[:,0]</code> with this.</p>
  <pre><code>&quot;&quot;&quot; scipy sparse A[:,0] = ndarray ValueError &quot;&quot;&quot;
  # sparse A[0,:] = ndarray works, sparse A[:,0] = ndarray raises ValueError
  # https://stackoverflow.com/search?q=[scipy] [sparse-matrix] ValueError  &gt; 100
  
  import numpy as np
  from scipy import sparse
  # import warnings
  # warnings.simplefilter( &quot;ignore&quot;, sparse.SparseEfficiencyWarning )
  
  def versionstr():
      import numpy, scipy, sys
      return &quot;versions: numpy %s  scipy %s  python %s &quot; % (
          numpy.__version__, scipy.__version__ , sys.version.split()[0] )
  
  print( versionstr() )  # 11 Sep 2020: numpy 1.19.2  scipy 1.5.2  python 3.7.6
  
  #...........................................................................
  n = 3
  ones = np.ones( n )
  
  for A in [
          np.eye(n),
          sparse.eye( n ).tolil(),
          sparse.eye( n ).tocsr(),
          sparse.eye( n ).tocsr(),
          ]:
      print( &quot;\n-- A:&quot;, type(A).__name__, A.shape )
      print( &quot;A[0,:] = ones&quot; )
      A[0,:] = ones
      print( &quot;A: \n&quot;, getattr( A, &quot;A&quot;, A ))  # dense
  
          # first column = ones --
      if sparse.issparse( A ):
          A[:,0] = ones.reshape( n, 1 )   # ok
          A[:,0] = np.matrix( ones ).T    # ok
          A[range(n),0] = ones            # ok
      try:
          print( &quot;A[:,0] = ones&quot; )
          A[:,0] = ones                   # A dense ok, A sparse ValueError
      except ValueError as msg:
          print( &quot;ValueError:&quot;, msg )
          # ValueError: cannot reshape array of size 9 into shape (3,1)
  </code></pre>