Transition Matrix in Dataframe Not Passing the Value <p>I am trying to implement transition matrix. </p> <p>Both data and transition matrix are in DataFrames using Pandas </p> <pre><code>states_mat = pd.DataFrame(None, index=range(0,24), columns=range(0,24)) def states_update(data): states_vec = data['hr'] # Do nothing if there is no sequence if len(states_vec) &lt; 2: return for i in xrange(1, len(states_vec)): prev = states_vec[i-1] curr = states_vec[i] states_mat[curr][prev] += 1 </code></pre> <p>Data are in int64 type </p> <p>It is not updating +1 count as I wanted. I believe it is some kind of type issue, but not sure how to force the type. I am using DataFrame for my data as I want to use group function to split the data and apply the above function. Any suggestions? </p>