title: "Can not convert a ndarray into a Tensor or Operation" using pandas dataframe in tensorflow
body: <p>I am learning to do some basic Tensorflow and I ran into some problem. I am trying to load data from a file using Pandas, and then perform K-nearest neighbor on the dataset, However, I keep running into problem <br></p>
  
  <p>It seems that Tensorflow does not work with ndarray from numpy, I am stuck here for two days now. I am wondering what is the best way to load data from a CSV file into Tensorflow?</p>
  
  <blockquote>
    <p>TypeError: Fetch argument array([-70.837845, -62.241467, -37.82856 ,
    -55.596767], dtype=float32) has invalid type , must be a string or Tensor. (Can not convert a ndarray into a Tensor
    or Operation.)</p>
  </blockquote>
  
  <pre><code>import numpy as npfrom sklearn import preprocessing
  from sklearn.model_selection import train_test_split
  import pandas as pd
  import tensorflow as tf
  import time
  
  Neighbors = 4
  Training_step=1
  
  data_frame=pd.read_csv('./data/breast-cancer-
  wisconsin.csv',encoding='gbk')
  # replace missing data with outlier inplace
  data_frame.replace('?',-99999,inplace=True)
  Y=np.array(data_frame['class'])
  
  data_frame.drop(['id'],1,inplace=True)
  X=np.array(data_frame.drop(['class'],1))
  
  # splits dataset for cross validation x_train,x_test,y_train,y_test=train_test_split(X,Y,test_size=0.3,random_state=0)
  y_train.shape=(489,1)
  
  # tf Graph Input
  x_training = tf.placeholder("float",[None,9],name="x_training_ph")
  y_training = tf.placeholder("float",[None,1],name="y_training_ph")
  x_testing = tf.placeholder("float",[9],name="x_testing_ph")
  
  eucli_distance =tf.negative(tf.sqrt(tf.reduce_sum(tf.square(tf.subtract((x_training),         (x_testing))), axis=0)))
  
  values, indices = tf.nn.top_k(eucli_distance, k=Neighbors, sorted=False)
  
  nearest_neighbors = []
  for i in range(Neighbors):
      #Returns the index with the largest value across axes of a tensor.
      nearest_neighbors.append(tf.argmax(y_training[indices[i]], 0))
  
  #stack the tensor together
  neighbors_tensor = tf.stack(nearest_neighbors)
  
  #returns a tensor y containing all of the unique elements of x sorted         in the same order that they occur in x.
  # This operation also returns a tensor idx the same size as x that contains the index of each value of x in the unique output y
  y, idx, count = tf.unique_with_counts(neighbors_tensor)
  
  #This operation extracts a slice of size size from a tensor input     starting at the location specified by begin.
  #Get the closest neightbor
  pred = tf.slice(y, begin=[tf.argmax(count, 0)], size=tf.constant([1], dtype=tf.int64))[0]
  
  accuracy = 0.
  
  # Initializing the variables
  init = tf.global_variables_initializer()
  
  start_time=time.time()
  
  # Launch the graph
  with tf.Session() as sess:
      sess.run(init)
  
  # loop over test data
  for i in range(len(x_test)):
      # Get nearest neighbor
      # feed to place holder
  
      nn_index = sess.run(pred, feed_dict={x_training: x_train,     y_training : y_train, x_testing: x_test[i, :]})
      distance = sess.run(eucli_distance, feed_dict={x_training: x_train, y_training : y_train, x_testing: x_test[i, :]})
      print("Distnace is ", len(distance), " ", distance)
      values = sess.run(values, feed_dict={x_training: x_train, y_training : y_train, x_testing: x_test[i, :]})
      print("Value is ", len(values), " ", values)
      print("Case:", i, "Prediction:", nn_index,
           "True label", np.argmax(y_test[i]))
      #Calculate accuracy
      if nn_index == np.argmax(y_test[i]):
          accuracy += 1. / len(x_test)
      else:
          print("Not matched")
  print("==========================================")
  print('Neighbors:',Neighbors)
  print('Training step:',Training_step)
  print("Time used: %s second" % (time.time() - start_time))
  print("Accuracy:", accuracy)
  </code></pre>
  
  <p>Dataset I am using is the one from UCI, the sample is below:</p>
  
  <pre><code>id,clump_thickness,unif_cell_size,unif_cell_shape,marg_adhesion,single_epith_cell_size,bare_nuclei,bland_chromatin,normal_nucleoli,mitoses,class
  1000025,5,1,1,1,2,1,3,1,1,2
  1002945,5,4,4,5,7,10,3,2,1,2
  1015425,3,1,1,1,2,2,3,1,1,2
  1016277,6,8,8,1,3,4,3,7,1,2
  1017023,4,1,1,3,2,1,3,1,1,2
  1017122,8,10,10,8,7,10,9,7,1,4
  1018099,1,1,1,1,2,10,3,1,1,2
  </code></pre>