title: Dataset API 'flat_map' method producing error for same code which works with 'map' method
body: <p>I am trying to create a create a pipeline to read multiple CSV files using TensorFlow Dataset API and Pandas. However, using the <code>flat_map</code> method is producing errors. However, if I am using <code>map</code> method I am able to build the code and run it in session. This is the code I am using. I already opened <a href="https://github.com/tensorflow/tensorflow/issues/17415" rel="nofollow noreferrer">#17415</a> issue in TensorFlow Github repository. But apparently, it is not an error and they asked me to post here.</p>
  
  <pre><code>folder_name = './data/power_data/'
  file_names = os.listdir(folder_name)
  def _get_data_for_dataset(file_name,rows=100):#
      print(file_name.decode())
  
      df_input=pd.read_csv(os.path.join(folder_name, file_name.decode()),
                           usecols =['Wind_MWh','Actual_Load_MWh'],nrows = rows)
      X_data = df_input.as_matrix()
      X_data.astype('float32', copy=False)
  
      return X_data
  dataset = tf.data.Dataset.from_tensor_slices(file_names)
  dataset = dataset.flat_map(lambda file_name: tf.py_func(_get_data_for_dataset, 
  [file_name], tf.float64))
  dataset= dataset.batch(2)
  fiter = dataset.make_one_shot_iterator()
  get_batch = iter.get_next()
  </code></pre>
  
  <p>I get the following error: <code>map_func must return a Dataset object</code>. The pipeline works without error when I use <code>map</code> but it doesn't give the output I want. For example, if Pandas is reading N rows from each of my CSV files I want the pipeline to concatenate data from B files and give me an array with shape (N*B, 2). Instead, it is giving me (B, N,2) where B is the Batch size. <code>map</code> is adding another axis instead of concatenating on the existing axis. From what I understood in the documentation <code>flat_map</code> is supposed to give a flatted output. In the documentation, both <code>map</code> and <code>flat_map</code> returns type Dataset. So how is my code working with map and not with flat_map?</p>
  
  <p>It would also great if you could point me towards code where Dataset API has been used with Pandas module.</p>