title: Accessing position in structure in python
body: <p>i want to use an array N of 8 columns and df1.shape[0] rows and i wanna compare the values of an array state and antoher array action and increment the value of N at the adequate position [i,j] based on the value of state i and  the value of the action j as shown below but i got this error any recommendation :</p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-79-66d1d4ab2df8&gt; in &lt;module&gt;()
       84     elif(state[i]==4 and action[i]==0):
       85          #access column 6 of N represents state1 for action 0
  ---&gt; 86         N[i:6]= N[i-1:6]+1
       87     else:
       88          #access column 7 of N represents state1 for action 1
  
  ValueError: could not broadcast input array from shape (2,8) into shape (1,8)
  </code></pre>
  
  <p>This is my code</p>
  
  <pre><code>N = np.zeros((df1.shape[0], 8))
  #for i in range(1,df1.shape[0],1):
  #N[df1['state'][i],df1['action'][i]]=N[state[i-1],action[i-1]]+1
  
  for i in range(1,df1.shape[0],1):
  if(state[i]==1 and action[i]==0):
      #access column 0 of N represents state1 for action 0
      N[i,0] = N[i-1,0]+1
  elif(state[i]==1 and action[i]==1):
       #access column 1 of N represents state1 for action 1
      N[i,1] = N[i-1,1]+1
  elif(state[i]==2 and action[i]==0):
       #access column 2 of N represents state1 for action 0
      N[i,2] = N[i-1,2]+1
  elif(state[i]==2 and action[i]==1):
       #access column 3 of N represents state1 for action 1
      N[i,3] = N[i-1,3]+1
  elif(state[i]==3 and action[i]==0):
      #access column 4 of N represents state1 for action 0
      N[i,4] = N[i-1,4]+1
  elif(state[i]==3 and action[i]==1):
       #access column 5 of N represents state1 for action 1
      N[i,5]= N[i-1,5]+1
  elif(state[i]==4 and action[i]==0):
       #access column 6 of N represents state1 for action 0
      N[i,6]= N[i-1,6]+1
  else:
       #access column 7 of N represents state1 for action 1
      N[i,7]= N[i-1,7]+1
  </code></pre>