Convert TensorFlow PrefetchDataset to a MapDataset

Hi is there a way to convert a prefetchdataset to a mapdataset (which is the default dataset type in tensorflow and also mostly used). I have a TF prefetch dataset as i have used to directly load a csv dataset into a tensorflow dataset. As the data is large i did not want to convert to pandas/list/numpy before converting to tensorflow.
As most functions support Mapdataset , i want to convert my prefetch dataset.
My dataset consists to multiple string and int columns and i have a requirement to sort the dataset on 2 int columns .

Hi @Sudh_Kumar, The dataset type will be how the dataset was created. For example,

If the dataset was created using dataset =[1, 2, 3]) then the type of dataset will be

If the dataset was created using dataset = then the type of dataset will be

The Prefetch dataset will be created when we apply the .prefetch method on the dataset. For example,

dataset =
prefetch_dataset = dataset.prefetch(3) 

To convert prefetch to mapdataset apply .map method on the prefetch_dataset. For example,

map_dataset= x: x)

Thank You!

Hi , Kiran thanks a lot for your detailed reply.

I have a csv dataset of 7-8 columns and hence i used to create a tensorflow dataset and all the data is stored in ordered dictionaries.

Hi @Sudh_Kumar, Once you have created a dataset using then the dataset type will be Now you can apply map function to convert it to For example, i have created a dataset using

titanic_file_path = tf.keras.utils.get_file("train.csv", "")

titanic_csv_ds =
    batch_size=5, # Artificially small to make examples easier to show.

type (titanic_csv_ds) 

Now if i apply a map on titanic_csv_ds

def map_function(features, label):
    return features, label



Thank You!