code: def df_to_documents(
      df: pd.DataFrame,
      page_content_columns: Union[List[str], str],
      url_column_name: str = None,
  ) -> List[Document]:
      """Converts a given dataframe to a list of documents"""
      documents = []
  
      if isinstance(page_content_columns, str):
          page_content_columns = [page_content_columns]
  
      for _, page_content_column in enumerate(page_content_columns):
          if page_content_column not in df.columns.tolist():
              raise ValueError(
                  f"page_content_column {page_content_column} not in dataframe columns"
              )
          if (
              url_column_name is not None
              and page_content_column == url_column_name
          ):
              documents.extend(
                  url_to_documents(df[page_content_column].tolist())
              )
              continue
  
          loader = DfLoader(
              data_frame=df, page_content_column=page_content_column
          )
          documents.extend(loader.load())
  
      return documents
  
imports: import json
  from dataclasses import dataclass
  from functools import lru_cache, partial
  from typing import Any, Dict, List, Union
  import html2text
  import openai
  import pandas
  import requests
  import writer
  from langchain import Writer
  from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
  from langchain.docstore.document import Document
  from langchain.document_loaders import DataFrameLoader
  from langchain.embeddings.base import Embeddings
  from langchain.embeddings.huggingface import HuggingFaceEmbeddings
  from langchain.vectorstores import FAISS, Chroma, VectorStore
  from pydantic import BaseModel, Extra, Field, validator
  from mindsdb.integrations.handlers.chromadb_handler.chromadb_handler import get_chromadb
  from mindsdb.integrations.handlers.rag_handler.exceptions import InvalidOpenAIModel, InvalidPromptTemplate, InvalidWriterModel, UnsupportedLLM, UnsupportedVectorStore
label_desc: Use image node_id 5 for calling a global function with example usage: df_to_documents(df, page_content_columns, url_column_name) and returns: documents