title: How to calculate the correlation between two cols of dataframe in pandas
body: <p>I am working on a method for calculating the correlation between to columns of data from a dataset. The dataset is constructed of 4 columns A1, A2, A3, and Class. My goal is remove A3 if the correlation between A1 &amp; A3 greater than 0.6 or if the correlation between A1 &amp; A3 is less than 0.6.</p>
  <p>A sample of the data set is given below:</p>
  <pre><code>A1,A2,A3,Class
  2,0.4631338,1.5,3
  8,0.7460648,3.0,3
  6,0.264391038,2.5,2
  5,0.4406713,2.3,1
  2,0.410438159,1.5,3
  2,0.302901816,1.5,2
  6,0.275869396,2.5,3
  8,0.084782428,3.0,3
  </code></pre>
  <p>The python program that I am using for this project is written like so</p>
  <pre><code>from numpy.core.defchararray import count
  import pandas as pd
  import numpy as np
  import numpy as np
  
  def main():
      s = pd.read_csv('A1-dm.csv')
      print(calculate_correlation(s))
  
  def calculate_correlation(s):
      # if correlation &gt; 0.6 or correlation &lt; 0.6 remove A3
      s = s['A1','A3']
      print(s)
      # return s.corr()
  
  main()
  </code></pre>
  <p>When I run my code I get the following error:</p>
  <pre><code>File &quot;C:\Users\physe\AppData\Roaming\Python\Python36\site-packages\pandas\core\indexes\base.py&quot;, line 2897, in get_loc
      raise KeyError(key) from err
  KeyError: ('A1', 'A3')
  </code></pre>
  <p>I've reviewed the documentation <a href="https://www.kite.com/python/answers/how-to-find-the-correlation-between-two-pandas-dataframe-columns-in-python" rel="nofollow noreferrer">here</a>. The issue that I'm facing is constructing a dataframe out 'A1' and 'A3'. How can this be done in pandas? Thanks in advance.</p>