Hi there! I'm just getting started with TF and pandas, so if this has an obvious answer that I'm just not finding, please point me toward the appropriate docs.--
I have a 2-column CSV file: match (Y/N) and text (a few sentences, some of which match my criteria and some of which don't).I'm following the example at https://www.tensorflow.org/tutorials/structured_data/feature_columns, and it works with their sample data which is all numerical (except for the popped label column).However, when I try to use my data, I getValueError: Can't convert Python sequence with mixed types to Tensor.As I mentioned, my input data is all text, but when I head() the dataframe, it seems pandas has injected a row number column.TypeError: Could not build a TypeSpec for 10972 blah blah this is my textI even removed all the digits from my sample data, so as far as I can tell, it's the pandas injected column number that from_tensor_slices doesn't like.Is there something I should use instead of from_tensor_slices , or ahead of it to prepare the data?
Or an easy way to tell it to treat the injected column numbers as text?
Or tell it to ignore it?This is the example code I copied from the above link.Thanks for any guidance you can give!# A utility method to create a tf.data dataset from a Pandas Dataframe
def df_to_dataset(dataframe, shuffle=True, batch_size=32):
dataframe = dataframe.copy()
labels = dataframe.pop('target')
ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels)) # FAILS HERE
if shuffle:
ds = ds.shuffle(buffer_size=len(dataframe))
ds = ds.batch(batch_size)
return ds
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/49b8e490-1c73-4090-9c5b-08b9da718b1e%40tensorflow.org.
• • • • | Paige Bailey Product Manager (TensorFlow) @DynamicWebPaige
|
To unsubscribe from this group and stop receiving emails from it, send an email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/49b8e490-1c73-4090-9c5b-08b9da718b1e%40tensorflow.org.