docstr: Creates a combined (training and test) dataframe by iterating through all the images and labels.
docstr_tok: ["Creates","a","combined","(","training","and","test",")","dataframe","by","iterating","through","all","the","images","and","labels","."]
code: def output_training_and_test_data(self):
      """Creates a combined (training and test) dataframe by iterating through all the images and labels."""
      dataframes = []
      for name in ["training", "testing"]:
          labels = []
          paths = []
          splits = []
          for i in range(NUM_LABELS):
              label_dir = f"{name}/{i}"
              img_dir = os.path.join(
                  self.processed_dataset_dir, label_dir
              )
              for file in os.listdir(img_dir):
                  if file.endswith(".png"):
                      labels.append(str(i))
                      paths.append(os.path.join(img_dir, file))
                      splits.append(0 if name == "training" else 2)
          dataframes.append(
              pd.DataFrame(
                  {
                      "image_path": paths,
                      "label": labels,
                      "split": splits,
                  }
              )
          )
      return pd.concat(dataframes, ignore_index=True)
  
file_path: ludwig/ludwig/datasets/loaders/mnist.py
imports: import logging
  import os
  import struct
  from multiprocessing.pool import ThreadPool
  from typing import List, Optional
  import numpy
  import pandas
  import torch
  from ludwig.datasets.dataset_config import DatasetConfig
  from ludwig.datasets.loaders.dataset_loader import DatasetLoader
  from ludwig.utils.fs_utils import makedirs
label_desc: Use image node_id 6 for calling the MNISTLoader obj's underlying member method code with example usage: obj.output_training_and_test_data() and returns: pd