docstr: Plots the data in a scrollable table.
  We limit the number of rows to max 600 to avoid rendering issues in Wave.
  As the data visualization is instantiated on every page load, we cache the
  data visualization in a parquet file.
docstr_tok: ["Plots","the","data","in","a","scrollable","table",".","We","limit","the","number","of","rows","to","max","600","to","avoid","rendering","issues","in","Wave",".","As","the","data","visualization","is","instantiated","on","every","page","load",",","we","cache","the","data","visualization","in","a","parquet","file","."]
code: def plot_data(cls, cfg) -> PlotData:
      """
      Plots the data in a scrollable table.
      We limit the number of rows to max 600 to avoid rendering issues in Wave.
      As the data visualization is instantiated on every page load, we cache the
      data visualization in a parquet file.
      """
      config_id = (
          str(cfg.dataset.train_dataframe)
          + str(cfg.dataset.system_column)
          + str(cfg.dataset.prompt_column)
          + str(cfg.dataset.answer_column)
          + str(cfg.dataset.parent_id_column)
      )
      config_hash = hashlib.md5(config_id.encode()).hexdigest()
      path = os.path.join(
          os.path.dirname(cfg.dataset.train_dataframe),
          f"__meta_info__{config_hash}_data_viz.parquet",
      )
      if os.path.exists(path):
          return PlotData(path, encoding="df")
  
      df = read_dataframe_drop_missing_labels(
          cfg.dataset.train_dataframe, cfg
      )
  
      conversations = get_conversation_chains(
          df, cfg, limit_chained_samples=True
      )
  
      # Limit to max 15 prompt-conversation-answer rounds
      # This yields to max 5 * sum_{i=1}^{15} i = 600 rows in the DataFrame
      max_conversation_length = min(
          max(
              [
                  len(conversation["prompts"])
                  for conversation in conversations
              ]
          ),
          15,
      )
  
      conversations_to_display = []
      for conversation_length in range(1, max_conversation_length + 1):
          conversations_to_display += [
              conversation
              for conversation in conversations
              if len(conversation["prompts"]) == conversation_length
          ][:5]
  
      # Convert into a scrollable table by transposing the dataframe
      df_transposed = pd.DataFrame(
          columns=["Sample Number", "Field", "Content"]
      )
  
      i = 0
      for sample_number, conversation in enumerate(
          conversations_to_display
      ):
          if conversation["systems"][0] != "":
              df_transposed.loc[i] = [
                  sample_number,
                  "System",
                  conversation["systems"][0],
              ]
              i += 1
          for prompt, answer in zip(
              conversation["prompts"], conversation["answers"]
          ):
              df_transposed.loc[i] = [
                  sample_number,
                  "Prompt",
                  prompt,
              ]
              i += 1
              df_transposed.loc[i] = [
                  sample_number,
                  "Answer",
                  answer,
              ]
              i += 1
  
      df_transposed["Content"] = df_transposed["Content"].apply(
          format_for_markdown_visualization
      )
  
      df_transposed.to_parquet(path)
  
      return PlotData(path, encoding="df")
  
file_path: h2o-llmstudio/llm_studio/src/plots/text_causal_language_modeling_plots.py
imports: import hashlib
  import os
  from typing import Any, Dict
  import pandas
  from llm_studio.src.datasets.conversation_chain_handler import get_conversation_chains
  from llm_studio.src.datasets.text_utils import get_tokenizer
  from llm_studio.src.utils.data_utils import read_dataframe_drop_missing_labels
  from llm_studio.src.utils.plot_utils import PlotData, format_for_markdown_visualization, list_to_markdown_representation
label_desc: Use image node_id 2 for calling the Plots obj's underlying member method code with example usage: obj.plot_data(cls, cfg) and returns: PlotData, PlotData