code: def from_pandas(
      df: pd.DataFrame,
      source: Union[str, DatasetSource] = None,
      targets: Optional[str] = None,
      name: Optional[str] = None,
      digest: Optional[str] = None,
      predictions: Optional[str] = None,
  ) -> PandasDataset:
      """
      Constructs a :py:class:`PandasDataset <mlflow.data.pandas_dataset.PandasDataset>` instance from
      a Pandas DataFrame, optional targets, optional predictions, and source.
  
      Args:
          df: A Pandas DataFrame.
          source: The source from which the DataFrame was derived, e.g. a filesystem
              path, an S3 URI, an HTTPS URL, a delta table name with version, or
              spark table etc. ``source`` may be specified as a URI, a path-like string,
              or an instance of
              :py:class:`DatasetSource <mlflow.data.dataset_source.DatasetSource>`.
              If unspecified, the source is assumed to be the code location
              (e.g. notebook cell, script, etc.) where
              :py:func:`from_pandas <mlflow.data.from_pandas>` is being called.
          targets: An optional target column name for supervised training. This column
              must be present in the dataframe (``df``).
          name: The name of the dataset. If unspecified, a name is generated.
          digest: The dataset digest (hash). If unspecified, a digest is computed
              automatically.
          predictions: An optional predictions column name for model evaluation. This column
              must be present in the dataframe (``df``).
  
      .. testcode:: python
          :caption: Example
  
          import mlflow
          import pandas as pd
  
          x = pd.DataFrame(
              [["tom", 10, 1, 1], ["nick", 15, 0, 1], ["juli", 14, 1, 1]],
              columns=["Name", "Age", "Label", "ModelOutput"],
          )
          dataset = mlflow.data.from_pandas(x, targets="Label", predictions="ModelOutput")
      """
  
      from mlflow.data.code_dataset_source import CodeDatasetSource
      from mlflow.data.dataset_source_registry import (
          resolve_dataset_source,
      )
      from mlflow.tracking.context import registry
  
      if source is not None:
          if isinstance(source, DatasetSource):
              resolved_source = source
          else:
              resolved_source = resolve_dataset_source(
                  source,
              )
      else:
          context_tags = registry.resolve_tags()
          resolved_source = CodeDatasetSource(tags=context_tags)
      return PandasDataset(
          df=df,
          source=resolved_source,
          targets=targets,
          name=name,
          digest=digest,
          predictions=predictions,
      )
  
imports: import json
  import logging
  from functools import cached_property
  from typing import Any, Dict, Optional, Union
  import pandas
  from mlflow.data.dataset import Dataset
  from mlflow.data.dataset_source import DatasetSource
  from mlflow.data.digest_utils import compute_pandas_digest
  from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin, PyFuncInputsOutputs
  from mlflow.exceptions import MlflowException
  from mlflow.models.evaluation.base import EvaluationDataset
  from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
  from mlflow.types import Schema
  from mlflow.types.utils import _infer_schema
  from mlflow.utils.annotations import experimental
label_desc: Use image node_id 1 for calling a global function with example usage: from_pandas(df, source, targets, name, digest, predictions) and returns: PandasDataset