def pivot(self, index: Optional[Name]=None, columns: Optional[Name]=None, values: Optional[Name]=None) -> 'DataFrame':
    '\n        Return reshaped DataFrame organized by given index / column values.\n\n        Reshape data (produce a "pivot" table) based on column values. Uses\n        unique values from specified `index` / `columns` to form axes of the\n        resulting DataFrame. This function does not support data\n        aggregation.\n\n        Parameters\n        ----------\n        index : string, optional\n            Column to use to make new frame\'s index. If None, uses\n            existing index.\n        columns : string\n            Column to use to make new frame\'s columns.\n        values : string, object or a list of the previous\n            Column(s) to use for populating new frame\'s values.\n\n        Returns\n        -------\n        DataFrame\n            Returns reshaped DataFrame.\n\n        See Also\n        --------\n        DataFrame.pivot_table : Generalization of pivot that can handle\n            duplicate values for one index/column pair.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'foo\': [\'one\', \'one\', \'one\', \'two\', \'two\',\n        ...                            \'two\'],\n        ...                    \'bar\': [\'A\', \'B\', \'C\', \'A\', \'B\', \'C\'],\n        ...                    \'baz\': [1, 2, 3, 4, 5, 6],\n        ...                    \'zoo\': [\'x\', \'y\', \'z\', \'q\', \'w\', \'t\']},\n        ...                   columns=[\'foo\', \'bar\', \'baz\', \'zoo\'])\n        >>> df\n           foo bar  baz zoo\n        0  one   A    1   x\n        1  one   B    2   y\n        2  one   C    3   z\n        3  two   A    4   q\n        4  two   B    5   w\n        5  two   C    6   t\n\n        >>> df.pivot(index=\'foo\', columns=\'bar\', values=\'baz\').sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        bar  A  B  C\n        foo\n        one  1  2  3\n        two  4  5  6\n\n        >>> df.pivot(columns=\'bar\', values=\'baz\').sort_index()  # doctest: +NORMALIZE_WHITESPACE\n        bar  A    B    C\n        0  1.0  NaN  NaN\n        1  NaN  2.0  NaN\n        2  NaN  NaN  3.0\n        3  4.0  NaN  NaN\n        4  NaN  5.0  NaN\n        5  NaN  NaN  6.0\n\n        Notice that, unlike pandas raises an ValueError when duplicated values are found,\n        pandas-on-Spark\'s pivot still works with its first value it meets during operation because\n        pivot is an expensive operation and it is preferred to permissively execute over failing\n        fast when processing large data.\n\n        >>> df = ps.DataFrame({"foo": [\'one\', \'one\', \'two\', \'two\'],\n        ...                    "bar": [\'A\', \'A\', \'B\', \'C\'],\n        ...                    "baz": [1, 2, 3, 4]}, columns=[\'foo\', \'bar\', \'baz\'])\n        >>> df\n           foo bar  baz\n        0  one   A    1\n        1  one   A    2\n        2  two   B    3\n        3  two   C    4\n\n        >>> df.pivot(index=\'foo\', columns=\'bar\', values=\'baz\').sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        bar    A    B    C\n        foo\n        one  1.0  NaN  NaN\n        two  NaN  3.0  4.0\n\n        It also support multi-index and multi-index column.\n        >>> df.columns = pd.MultiIndex.from_tuples([(\'a\', \'foo\'), (\'a\', \'bar\'), (\'b\', \'baz\')])\n\n        >>> df = df.set_index((\'a\', \'bar\'), append=True)\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                      a   b\n                    foo baz\n          (a, bar)\n        0 A         one   1\n        1 A         one   2\n        2 B         two   3\n        3 C         two   4\n\n        >>> df.pivot(columns=(\'a\', \'foo\'), values=(\'b\', \'baz\')).sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        (\'a\', \'foo\')  one  two\n          (a, bar)\n        0 A           1.0  NaN\n        1 A           2.0  NaN\n        2 B           NaN  3.0\n        3 C           NaN  4.0\n\n        '
    if (columns is None):
        raise ValueError('columns should be set.')
    if (values is None):
        raise ValueError('values should be set.')
    should_use_existing_index = (index is not None)
    if should_use_existing_index:
        df = self
        index_labels = [index]
    else:
        with option_context('compute.default_index_type', 'distributed'):
            df = self.reset_index()
        index_labels = df._internal.column_labels[:self._internal.index_level]
    df = df.pivot_table(index=index_labels, columns=columns, values=values, aggfunc='first')
    if should_use_existing_index:
        return df
    else:
        internal = df._internal.copy(index_names=self._internal.index_names)
        return DataFrame(internal)
Return reshaped DataFrame organized by given index / column values.

Reshape data (produce a "pivot" table) based on column values. Uses
unique values from specified `index` / `columns` to form axes of the
resulting DataFrame. This function does not support data
aggregation.

Parameters
----------
index : string, optional
    Column to use to make new frame's index. If None, uses
    existing index.
columns : string
    Column to use to make new frame's columns.
values : string, object or a list of the previous
    Column(s) to use for populating new frame's values.

Returns
-------
DataFrame
    Returns reshaped DataFrame.

See Also
--------
DataFrame.pivot_table : Generalization of pivot that can handle
    duplicate values for one index/column pair.

Examples
--------
>>> df = ps.DataFrame({'foo': ['one', 'one', 'one', 'two', 'two',
...                            'two'],
...                    'bar': ['A', 'B', 'C', 'A', 'B', 'C'],
...                    'baz': [1, 2, 3, 4, 5, 6],
...                    'zoo': ['x', 'y', 'z', 'q', 'w', 't']},
...                   columns=['foo', 'bar', 'baz', 'zoo'])
>>> df
   foo bar  baz zoo
0  one   A    1   x
1  one   B    2   y
2  one   C    3   z
3  two   A    4   q
4  two   B    5   w
5  two   C    6   t

>>> df.pivot(index='foo', columns='bar', values='baz').sort_index()
... # doctest: +NORMALIZE_WHITESPACE
bar  A  B  C
foo
one  1  2  3
two  4  5  6

>>> df.pivot(columns='bar', values='baz').sort_index()  # doctest: +NORMALIZE_WHITESPACE
bar  A    B    C
0  1.0  NaN  NaN
1  NaN  2.0  NaN
2  NaN  NaN  3.0
3  4.0  NaN  NaN
4  NaN  5.0  NaN
5  NaN  NaN  6.0

Notice that, unlike pandas raises an ValueError when duplicated values are found,
pandas-on-Spark's pivot still works with its first value it meets during operation because
pivot is an expensive operation and it is preferred to permissively execute over failing
fast when processing large data.

>>> df = ps.DataFrame({"foo": ['one', 'one', 'two', 'two'],
...                    "bar": ['A', 'A', 'B', 'C'],
...                    "baz": [1, 2, 3, 4]}, columns=['foo', 'bar', 'baz'])
>>> df
   foo bar  baz
0  one   A    1
1  one   A    2
2  two   B    3
3  two   C    4

>>> df.pivot(index='foo', columns='bar', values='baz').sort_index()
... # doctest: +NORMALIZE_WHITESPACE
bar    A    B    C
foo
one  1.0  NaN  NaN
two  NaN  3.0  4.0

It also support multi-index and multi-index column.
>>> df.columns = pd.MultiIndex.from_tuples([('a', 'foo'), ('a', 'bar'), ('b', 'baz')])

>>> df = df.set_index(('a', 'bar'), append=True)
>>> df  # doctest: +NORMALIZE_WHITESPACE
              a   b
            foo baz
  (a, bar)
0 A         one   1
1 A         one   2
2 B         two   3
3 C         two   4

>>> df.pivot(columns=('a', 'foo'), values=('b', 'baz')).sort_index()
... # doctest: +NORMALIZE_WHITESPACE
('a', 'foo')  one  two
  (a, bar)
0 A           1.0  NaN
1 A           2.0  NaN
2 B           NaN  3.0
3 C           NaN  4.0
def pivot(self, index: Optional[Name]=None, columns: Optional[Name]=None, values: Optional[Name]=None) -> 'DataFrame':
    '\n        Return reshaped DataFrame organized by given index / column values.\n\n        Reshape data (produce a "pivot" table) based on column values. Uses\n        unique values from specified `index` / `columns` to form axes of the\n        resulting DataFrame. This function does not support data\n        aggregation.\n\n        Parameters\n        ----------\n        index : string, optional\n            Column to use to make new frame\'s index. If None, uses\n            existing index.\n        columns : string\n            Column to use to make new frame\'s columns.\n        values : string, object or a list of the previous\n            Column(s) to use for populating new frame\'s values.\n\n        Returns\n        -------\n        DataFrame\n            Returns reshaped DataFrame.\n\n        See Also\n        --------\n        DataFrame.pivot_table : Generalization of pivot that can handle\n            duplicate values for one index/column pair.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'foo\': [\'one\', \'one\', \'one\', \'two\', \'two\',\n        ...                            \'two\'],\n        ...                    \'bar\': [\'A\', \'B\', \'C\', \'A\', \'B\', \'C\'],\n        ...                    \'baz\': [1, 2, 3, 4, 5, 6],\n        ...                    \'zoo\': [\'x\', \'y\', \'z\', \'q\', \'w\', \'t\']},\n        ...                   columns=[\'foo\', \'bar\', \'baz\', \'zoo\'])\n        >>> df\n           foo bar  baz zoo\n        0  one   A    1   x\n        1  one   B    2   y\n        2  one   C    3   z\n        3  two   A    4   q\n        4  two   B    5   w\n        5  two   C    6   t\n\n        >>> df.pivot(index=\'foo\', columns=\'bar\', values=\'baz\').sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        bar  A  B  C\n        foo\n        one  1  2  3\n        two  4  5  6\n\n        >>> df.pivot(columns=\'bar\', values=\'baz\').sort_index()  # doctest: +NORMALIZE_WHITESPACE\n        bar  A    B    C\n        0  1.0  NaN  NaN\n        1  NaN  2.0  NaN\n        2  NaN  NaN  3.0\n        3  4.0  NaN  NaN\n        4  NaN  5.0  NaN\n        5  NaN  NaN  6.0\n\n        Notice that, unlike pandas raises an ValueError when duplicated values are found,\n        pandas-on-Spark\'s pivot still works with its first value it meets during operation because\n        pivot is an expensive operation and it is preferred to permissively execute over failing\n        fast when processing large data.\n\n        >>> df = ps.DataFrame({"foo": [\'one\', \'one\', \'two\', \'two\'],\n        ...                    "bar": [\'A\', \'A\', \'B\', \'C\'],\n        ...                    "baz": [1, 2, 3, 4]}, columns=[\'foo\', \'bar\', \'baz\'])\n        >>> df\n           foo bar  baz\n        0  one   A    1\n        1  one   A    2\n        2  two   B    3\n        3  two   C    4\n\n        >>> df.pivot(index=\'foo\', columns=\'bar\', values=\'baz\').sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        bar    A    B    C\n        foo\n        one  1.0  NaN  NaN\n        two  NaN  3.0  4.0\n\n        It also support multi-index and multi-index column.\n        >>> df.columns = pd.MultiIndex.from_tuples([(\'a\', \'foo\'), (\'a\', \'bar\'), (\'b\', \'baz\')])\n\n        >>> df = df.set_index((\'a\', \'bar\'), append=True)\n        >>> df  # doctest: +NORMALIZE_WHITESPACE\n                      a   b\n                    foo baz\n          (a, bar)\n        0 A         one   1\n        1 A         one   2\n        2 B         two   3\n        3 C         two   4\n\n        >>> df.pivot(columns=(\'a\', \'foo\'), values=(\'b\', \'baz\')).sort_index()\n        ... # doctest: +NORMALIZE_WHITESPACE\n        (\'a\', \'foo\')  one  two\n          (a, bar)\n        0 A           1.0  NaN\n        1 A           2.0  NaN\n        2 B           NaN  3.0\n        3 C           NaN  4.0\n\n        '
    if (columns is None):
        raise ValueError('columns should be set.')
    if (values is None):
        raise ValueError('values should be set.')
    should_use_existing_index = (index is not None)
    if should_use_existing_index:
        df = self
        index_labels = [index]
    else:
        with option_context('compute.default_index_type', 'distributed'):
            df = self.reset_index()
        index_labels = df._internal.column_labels[:self._internal.index_level]
    df = df.pivot_table(index=index_labels, columns=columns, values=values, aggfunc='first')
    if should_use_existing_index:
        return df
    else:
        internal = df._internal.copy(index_names=self._internal.index_names)
        return DataFrame(internal)