code: def pivot(
      data: DataFrame,
      *,
      columns: IndexLabel,
      index: IndexLabel | lib.NoDefault = lib.NoDefault,
      values: IndexLabel | lib.NoDefault = lib.NoDefault,
  ) -> DataFrame:
      columns_listlike = com.convert_to_list_like(columns)
  
      # If columns is None we will create a MultiIndex level with None as name
      # which might cause duplicated names because None is the default for
      # level names
      data = data.copy(deep=False)
      data.index = data.index.copy()
      data.index.names = [
          name if name is not None else lib.NoDefault
          for name in data.index.names
      ]
  
      indexed: DataFrame | Series
      if values is lib.NoDefault:
          if index is not lib.NoDefault:
              cols = com.convert_to_list_like(index)
          else:
              cols = []
  
          append = index is lib.NoDefault
          # error: Unsupported operand types for + ("List[Any]" and "ExtensionArray")
          # error: Unsupported left operand type for + ("ExtensionArray")
          indexed = data.set_index(
              cols + columns_listlike, append=append  # type: ignore[operator]
          )
      else:
          if index is lib.NoDefault:
              if isinstance(data.index, MultiIndex):
                  # GH 23955
                  index_list = [
                      data.index.get_level_values(i)
                      for i in range(data.index.nlevels)
                  ]
              else:
                  index_list = [
                      Series(data.index, name=data.index.name)
                  ]
          else:
              index_list = [
                  data[idx] for idx in com.convert_to_list_like(index)
              ]
  
          data_columns = [data[col] for col in columns_listlike]
          index_list.extend(data_columns)
          multiindex = MultiIndex.from_arrays(index_list)
  
          if is_list_like(values) and not isinstance(values, tuple):
              # Exclude tuple because it is seen as a single column name
              values = cast(Sequence[Hashable], values)
              indexed = data._constructor(
                  data[values]._values, index=multiindex, columns=values
              )
          else:
              indexed = data._constructor_sliced(
                  data[values]._values, index=multiindex
              )
      # error: Argument 1 to "unstack" of "DataFrame" has incompatible type "Union
      # [List[Any], ExtensionArray, ndarray[Any, Any], Index, Series]"; expected
      # "Hashable"
      result = indexed.unstack(columns_listlike)  # type: ignore[arg-type]
      result.index.names = [
          name if name is not lib.NoDefault else None
          for name in result.index.names
      ]
  
      return result
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable, Hashable, Sequence, cast
  import numpy
  from pandas._libs import lib
  from pandas._typing import AggFuncType, AggFuncTypeBase, AggFuncTypeDict, IndexLabel
  from pandas.util._decorators import Appender, Substitution
  from pandas.core.dtypes.cast import maybe_downcast_to_dtype
  from pandas.core.dtypes.common import is_extension_array_dtype, is_integer_dtype, is_list_like, is_nested_list_like, is_scalar
  from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
  import pandas.core.common
  from pandas.core.frame import _shared_docs
  from pandas.core.groupby import Grouper
  from pandas.core.indexes.api import Index, MultiIndex, get_objs_combined_axis
  from pandas.core.reshape.concat import concat
  from pandas.core.reshape.util import cartesian_product
  from pandas.core.series import Series
label_desc: Use image node_id 8 for calling a global function with example usage: pivot(data) and returns: result