code: def init(cls, eltype, data, kdims, vdims):
      element_params = eltype.param.objects()
      kdim_param = element_params["kdims"]
      vdim_param = element_params["vdims"]
      if util.is_series(data):
          name = data.name or util.anonymous_dimension_label
          data = data.to_frame(name=name)
      if util.is_dataframe(data):
          ncols = len(data.columns)
          index_names = (
              data.index.names
              if isinstance(data, pd.DataFrame)
              else [data.index.name]
          )
          if index_names == [None]:
              index_names = ["index"]
          if eltype._auto_indexable_1d and ncols == 1 and kdims is None:
              kdims = list(index_names)
  
          if isinstance(kdim_param.bounds[1], int):
              ndim = min(
                  [kdim_param.bounds[1], len(kdim_param.default)]
              )
          else:
              ndim = None
          nvdim = (
              vdim_param.bounds[1]
              if isinstance(vdim_param.bounds[1], int)
              else None
          )
          if kdims and vdims is None:
              vdims = [c for c in data.columns if c not in kdims]
          elif vdims and kdims is None:
              kdims = [c for c in data.columns if c not in vdims][:ndim]
          elif kdims is None:
              kdims = list(data.columns[:ndim])
              if vdims is None:
                  vdims = [
                      d
                      for d in data.columns[
                          ndim : ((ndim + nvdim) if nvdim else None)
                      ]
                      if d not in kdims
                  ]
          elif kdims == [] and vdims is None:
              vdims = list(data.columns[: nvdim if nvdim else None])
  
          if any(
              not isinstance(d, (str, Dimension)) for d in kdims + vdims
          ):
              raise DataError(
                  "Having a non-string as a column name in a DataFrame is not supported."
              )
  
          # Handle reset of index if kdims reference index by name
          for kd in kdims:
              kd = dimension_name(kd)
              if kd in data.columns:
                  continue
              if any(
                  kd == ("index" if name is None else name)
                  for name in index_names
              ):
                  data = data.reset_index()
                  break
  
          if kdims:
              kdim = dimension_name(kdims[0])
              if (
                  eltype._auto_indexable_1d
                  and ncols == 1
                  and kdim not in data.columns
              ):
                  data = data.copy()
                  data.insert(0, kdim, np.arange(len(data)))
  
          for d in kdims + vdims:
              d = dimension_name(d)
              if len([c for c in data.columns if c == d]) > 1:
                  raise DataError(
                      "Dimensions may not reference duplicated DataFrame "
                      "columns (found duplicate %r columns). If you want to plot "
                      "a column against itself simply declare two dimensions "
                      "with the same name. " % d,
                      cls,
                  )
      else:
          # Check if data is of non-numeric type
          # Then use defined data type
          kdims = kdims if kdims else kdim_param.default
          vdims = vdims if vdims else vdim_param.default
          columns = list(
              util.unique_iterator(
                  [dimension_name(d) for d in kdims + vdims]
              )
          )
  
          if isinstance(data, dict) and all(c in data for c in columns):
              data = dict((d, data[d]) for d in columns)
          elif isinstance(data, list) and len(data) == 0:
              data = {c: np.array([]) for c in columns}
          elif isinstance(data, (list, dict)) and data in ([], {}):
              data = None
          elif (
              isinstance(data, dict)
              and not all(d in data for d in columns)
              and not any(
                  isinstance(v, np.ndarray) for v in data.values()
              )
          ):
              column_data = sorted(data.items())
              k, v = column_data[0]
              if len(util.wrap_tuple(k)) != len(kdims) or len(
                  util.wrap_tuple(v)
              ) != len(vdims):
                  raise ValueError(
                      "Dictionary data not understood, should contain a column "
                      "per dimension or a mapping between key and value dimension "
                      "values."
                  )
              column_data = zip(
                  *(
                      (util.wrap_tuple(k) + util.wrap_tuple(v))
                      for k, v in column_data
                  )
              )
              data = dict(
                  ((c, col) for c, col in zip(columns, column_data))
              )
          elif isinstance(data, np.ndarray):
              if data.ndim == 1:
                  if (
                      eltype._auto_indexable_1d
                      and len(kdims) + len(vdims) > 1
                  ):
                      data = (np.arange(len(data)), data)
                  else:
                      data = np.atleast_2d(data).T
              else:
                  data = tuple(data[:, i] for i in range(data.shape[1]))
  
          if isinstance(data, tuple):
              data = [
                  np.array(d) if not isinstance(d, np.ndarray) else d
                  for d in data
              ]
              min_dims = (kdim_param.bounds[0] or 0) + (
                  vdim_param.bounds[0] or 0
              )
              if any(d.ndim > 1 for d in data):
                  raise ValueError(
                      "PandasInterface cannot interpret multi-dimensional arrays."
                  )
              elif len(data) < min_dims:
                  raise DataError(
                      "Data contains fewer columns than the %s element expects. Expected "
                      "at least %d columns but found only %d columns."
                      % (eltype.__name__, min_dims, len(data))
                  )
              elif not cls.expanded(data):
                  raise ValueError(
                      "PandasInterface expects data to be of uniform shape."
                  )
              data = pd.DataFrame(
                  dict(zip(columns, data)), columns=columns
              )
          elif (
              isinstance(data, dict)
              and any(c not in data for c in columns)
          ) or (
              isinstance(data, list)
              and any(
                  isinstance(d, dict) and c not in d
                  for d in data
                  for c in columns
              )
          ):
              raise ValueError(
                  "PandasInterface could not find specified dimensions in the data."
              )
          else:
              data = pd.DataFrame(data, columns=columns)
      return data, {"kdims": kdims, "vdims": vdims}, {}
  
imports: import numpy
  import pandas
  from packaging.version import Version
  from pandas.api.types import is_numeric_dtype
  from ..None import util
  from ..dimension import Dimension, dimension_name
  from ..element import Element
  from ..ndmapping import NdMapping, item_check, sorted_context
  from .interface import DataError, Interface
  from .util import finite_range
label_desc: Use image node_id 2 for calling the PandasInterface obj's underlying member method code with example usage: obj.init(cls, eltype, data, kdims, vdims) and returns: data,  dict,  dict