How to apply Cramérs $V$ on a 2$\times$2 matrix I want to find the association between variables and Cramérs V works like a treat for matrices of sizes greater than 2$\times$2. However, for matrices with low frequencies, it does not work well. For the following contingency matrix, I get the result as 0.5. How can I account for the same?
  1 2  
a 2 0  
b 0 2  

Here is my code:
def cramers_stat(confusion_matrix):  
  chi2 = ss.chi2_contingency(confusion_matrix)[0]  
  n = confusion_matrix.sum().sum()  
  return np.sqrt(chi2 / (n*(min(confusion_matrix.shape)-1)))  
result=cramers_stat(confusion_matrix)  
print(result) 

confusion_matrix is my input, in this case the matrix I mentioned above. I understand for good results, I need a matrix frequency above 5, but for perfect association as the case above I expected the result to be 1.
 A: For that table, Cramer's V should be 1. 
From the relevant Wikipedia page, we can write $V$ in terms of the chi-squared value
$$V={\sqrt  {{\frac  {\chi ^{2}/n}{\min(k-1,r-1)}}}}$$
(this appears to be the formula you're attempting to implement).
Here all the expected values are 1 (row total x column total / overall total), and so each cell's $(O_i-E_i)^2/E_i$ is $1$.
So $\chi^2=4$. Further, $n=4$ and $k$ and $r$ are each $2$ so $\min(k-1,r-1)=1$. Immediately we have $V=\sqrt{(4/4)/1}=1$.
(You should have carried out such a computation yourself! How are you checking your code is correctly implemented if you're not checking simple cases like this by hand?)
So you did something wrong somewhere. It may be that your chi-squared value has been corrected, for example, but any number of other things may be wrong (you don't say what any of the component variables' values were).
-- 
Edit: It turns out that the supposition I made in that last sentence above is the case -- the python function that computes the chi-square applies Yates' continuity correction by default, which would reduce the statistic and hence make Cramér's $V$ less than $1$; you will want the uncorrected chi-square for that. 
However, this doesn't necessarily account for the entire difference and you should check carefully the remaining parts of the calculation as well. 
