title: Chi-Squared test for independence with one data column as integer and other as object?
body: <p>I'm trying to perform hypothesis test for Independence in python but my one data column(finances) has float data type and other column(gender) has object data type.</p>
  
  <p>I have created the following hypothesis:
  Ho : finances are gender independent
  Ha : finances are gender dependent</p>
  
  <p>I tried directly using the inputs but I'm getting the following error:
  " could not convert string to float: 'female' "</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas      as pd
  import numpy       as np
  import scipy.stats as stats
  
  test = np.array(df['Gender'],df['Finances'])
  chi_sq_Stat, p_value, deg_freedom, exp_freq = stats.chi2_contingency(test)
  
  print('Chi-square statistic %3.5f P value %1.6f Degrees of freedom %d' %(chi_sq_Stat, p_value,deg_freedom))
  </code></pre>
  
  <p>I'm expecting some P value to verify my hypothesis. </p>
  
  <p>I have attached an image of data set </p>
  
  <p><a href="https://i.stack.imgur.com/Fz63R.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fz63R.jpg" alt="dataset"></a></p>