title: TensorFlow Dataset: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray)
body: <p>I am aware that similar questions have been asked perviously but none of the proposed solutions seems to work for me. I have the following <code>Pandas</code> Dataframe:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: right;"></th>
  <th style="text-align: left;">Title</th>
  <th style="text-align: right;">Author</th>
  <th style="text-align: right;">Target</th>
  <th style="text-align: right;">Tag0</th>
  <th style="text-align: right;">Tag1</th>
  <th style="text-align: right;">Tag2</th>
  <th style="text-align: right;">Tag3</th>
  <th style="text-align: right;">Tag4</th>
  <th style="text-align: right;">Tag5</th>
  <th style="text-align: right;">Tag6</th>
  <th style="text-align: right;">Tag7</th>
  <th style="text-align: right;">Tag8</th>
  <th style="text-align: right;">Tag9</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: right;">0</td>
  <td style="text-align: left;">Says Ron Johnson referred to &quot;The Lego Movie&quot; as an &quot;insidious anti-business conspiracy.&quot;</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">30</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">36</td>
  <td style="text-align: right;">35</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  </tr>
  <tr>
  <td style="text-align: right;">1</td>
  <td style="text-align: left;">&quot;Forty percent of the Fortune 500 were started either by immigrants or children of immigrants.&quot;</td>
  <td style="text-align: right;">1</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">9</td>
  <td style="text-align: right;">21</td>
  <td style="text-align: right;">5</td>
  <td style="text-align: right;">28</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I have vectorised <code>Title</code> attribute by means of <code>TextVectorization</code> layer in <code>Keras</code> obtaining the following Dataframe:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: right;"></th>
  <th style="text-align: left;">Title</th>
  <th style="text-align: right;">Author</th>
  <th style="text-align: right;">Target</th>
  <th style="text-align: right;">Tag0</th>
  <th style="text-align: right;">Tag1</th>
  <th style="text-align: right;">Tag2</th>
  <th style="text-align: right;">Tag3</th>
  <th style="text-align: right;">Tag4</th>
  <th style="text-align: right;">Tag5</th>
  <th style="text-align: right;">Tag6</th>
  <th style="text-align: right;">Tag7</th>
  <th style="text-align: right;">Tag8</th>
  <th style="text-align: right;">Tag9</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: right;">0</td>
  <td style="text-align: left;">[9415, 19483, 9066, 16820, 20256, 6959, 6931,...,0 ]</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">0</td>
  <td style="text-align: right;">3213</td>
  <td style="text-align: right;">3829</td>
  <td style="text-align: right;">223</td>
  <td style="text-align: right;">3140</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  <td style="text-align: right;">nan</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I want to transform this <code>Pandas</code> dataframe to a <code>TensorFlow</code> dataset. I have tried to achieve this using the following code:</p>
  <pre class="lang-py prettyprint-override"><code>dataset = tf.data.Dataset.from_tensor_slices((data.values, target.values))
  </code></pre>
  <p>Here is the error I am getting:</p>
  <pre><code>ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).
  </code></pre>
  <p><strong>By removing <code>Title</code> column the error goes away, then <code>Title</code> is the column that makes the error</strong>. <code>Title</code> looks like this:</p>
  <pre><code>print(data[&quot;Title&quot;].values)
  </code></pre>
  <pre><code>array([array([ 9415., 19483.,  9066., 16820., 20256.,  6959.,  6931.,  8539.,
         10705.,  1342.,  1896.,  4353., 14143.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.],
         ...,
         array([17497., 20189.,  4280.,  3460., 20256., 15754.,  9178.,  1114.,
         19441., 18731., 13875., 14018.,  5789.,  6959.,  8740., 13042.,
           929.,  9541.,   773., 19384.,  5659., 13042., 14578.,  2813.,
         17452.,   888.,  6206.,  6959., 14540.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.,     0.,
             0.,     0.,     0.,     0.,     0.,     0.,     0.],
        dtype=float32)], dtype=object)
  </code></pre>
  <h3>My question is: What is wrong with <code>Title</code>? What should I change ?</h3>
  <p>I am assuming that is related to the data type of the <code>numpy.ndarray</code> containing each <code>numpy.ndarray</code> title. As it be can seen above <code>dtype=object</code>. But I am not really sure.</p>
  <p>Thank you in advance!</p>
  <h2>Edit:</h2>
  <p>I found a work around to this issue by simply transforming the dataset to a <code>Numpy</code> ndarray.</p>
  <pre class="lang-py prettyprint-override"><code># To numpy
  numpy_dataset = data.to_numpy(dtype=&quot;&lt;U43&quot;)
  
  #Get Target
  target = data.pop(&quot;Target&quot;)
  
  #TF dataset
  dataset = tf.data.Dataset.from_tensor_slices((numpy_dataset, target.values))
  </code></pre>