title: Markov chain transition matrix outputing only '0.000's
body: <p>I am attempting to produce a transformation matrix based on the first column of a csv file. There are 59 possible states, which are integers in a list.</p>
  
  <p>At the moment my output is simply a long list of '0.000s' - in the correct size as far as I can tell (59*59), but without the weights that it should have.</p>
  
  <p>The data is definitely in the activities list, because it can be printed separately.</p>
  
  <pre><code>import csv
  data = open('file.csv')
  
  csv_data = csv.reader(data)
  data_lines = list(csv_data)
  
  activities = []
  
  for row in data_lines[:5954]:
      activities.append(row[0])
  
  activities = list(map(int, activities))
  
  def transition_matrix(activities):
      n = 59 #number of states
  
      m = [[0]*n for _ in range(n)]
  
      for (i,j) in zip(activities,activities[1:]):
          m[i][j] += 1
  
      #now convert to probabilities:
      for row in m:
          s = sum(row)
          if s &gt; 0:
              row[:] = [f/s for f in row]
      return m
  
  t = [activities]
  m = transition_matrix(t)
  for row in m: print(' '.join('{0:.3f}'.format(x) for x in row))
  </code></pre>