title: How to convert dataframe to 1D array ?
body: <p>First of all apologies. I am very new to pandas, scikit learn and python. So I am sure I am doing something silly. Let me give a little background.</p>
  
  <p>I am trying to run KNeighborsClassifier from scikit learn (python)
  Following is my strategy</p>
  
  <pre><code>#Reading the Training set
  data = pd.read_csv('Path_TO_File\\Train_Set.csv', sep=',') # reading CSV File
  X = data[['Attribute 1','Attribute 2']] 
  y = data['Target_Column'] # the output is a Dataframe of single column with many rows
  neigh = KNeighborsClassifier(n_neighbors=3)
  neigh.fit(X,y) 
  </code></pre>
  
  <p>Next I try to read Test data</p>
  
  <pre><code>test = pd.read_csv('PATH_TO_FILE\\Test.csv', sep=',')
  t = test[['Attribute 1','Attribute 2']] 
  pred = neigh.predict(t)
  actual = test['Target_Column']
  </code></pre>
  
  <p>Next I try to check the accuracy by following function which is throwing error.</p>
  
  <pre><code>accuracy=neigh.score(actual,pred)
  </code></pre>
  
  <p>ERROR: ValueError: could not convert string to float: N</p>
  
  <p>I checked actual and pred both and they are of following data type and content</p>
  
  <pre><code>actual
  Out[161]: 
      Target_Column
  0             Y
  1             N
  :
  
  [614 rows x 1 columns]
  
  pred
  Out[162]: 
  array(['Y', 'N', .....'N'], dtype=object)
  </code></pre>
  
  <p>N.B : pred has 614 values.</p>
  
  <p>I tried to convert "actual" variable to 1D array I might be able to execute the function however, I am not successful. </p>
  
  <p>I think I need to do following two things, however, was not able to do so (after googling it)</p>
  
  <p>1) Convert actual into 1Dimen array
  2) Making a transpose of the 1Dimen array since the pred has 614 columns. </p>
  
  <p>Please let me know how to correct the function.</p>
  
  <p>Thanks in advance !
  Raj</p>