How can I filter and balance a Windowed Tensorflow dataset with a binary classification label, based on the label?
Figured it out. Had to specify the position of y[0] instead of just y as I guess it's not just an integer but rather an array or tuple with one item, and the filter had to be done after the flatmap. 

tensor= tf.data.Dataset.from_tensor_slices((tf.constant(DFrame[DFrame.columns.values[:-1]].values), tf.constant(DFrame[DFrame.columns.values[-1]].values)))

tensor = tensor.window(hindsight,1,1,True)

tensor = tensor.shuffle(1000)

tensor = tensor.filter(lambda x,y: tf.equal(y, 0))

tensor = tensor.flat_map(lambda x,y:tf.data.Dataset.zip((x.batch(hindsight), y.batch(1))))

tensor = tensor.batch(Batch_size).prefetch(1)



TypeError: Failed to convert object of type &lt;class 'tensorflow.python.data.ops.dataset_ops._VariantDataset'&gt; to Tensor. Contents: &lt;_VariantDataset shapes: (), types: tf.int64&gt;. Consider casting elements to a supported type.