def melt(self, id_vars: Optional[Union[(Name, List[Name])]]=None, value_vars: Optional[Union[(Name, List[Name])]]=None, var_name: Optional[Union[(str, List[str])]]=None, value_name: str='value') -> 'DataFrame':
    '\n        Unpivot a DataFrame from wide format to long format, optionally\n        leaving identifier variables set.\n\n        This function is useful to massage a DataFrame into a format where one\n        or more columns are identifier variables (`id_vars`), while all other\n        columns, considered measured variables (`value_vars`), are "unpivoted" to\n        the row axis, leaving just two non-identifier columns, \'variable\' and\n        \'value\'.\n\n        Parameters\n        ----------\n        frame : DataFrame\n        id_vars : tuple, list, or ndarray, optional\n            Column(s) to use as identifier variables.\n        value_vars : tuple, list, or ndarray, optional\n            Column(s) to unpivot. If not specified, uses all columns that\n            are not set as `id_vars`.\n        var_name : scalar, default \'variable\'\n            Name to use for the \'variable\' column. If None it uses `frame.columns.name` or\n            ‘variable’.\n        value_name : scalar, default \'value\'\n            Name to use for the \'value\' column.\n\n        Returns\n        -------\n        DataFrame\n            Unpivoted DataFrame.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'A\': {0: \'a\', 1: \'b\', 2: \'c\'},\n        ...                    \'B\': {0: 1, 1: 3, 2: 5},\n        ...                    \'C\': {0: 2, 1: 4, 2: 6}},\n        ...                   columns=[\'A\', \'B\', \'C\'])\n        >>> df\n           A  B  C\n        0  a  1  2\n        1  b  3  4\n        2  c  5  6\n\n        >>> ps.melt(df)\n          variable value\n        0        A     a\n        1        B     1\n        2        C     2\n        3        A     b\n        4        B     3\n        5        C     4\n        6        A     c\n        7        B     5\n        8        C     6\n\n        >>> df.melt(id_vars=\'A\')\n           A variable  value\n        0  a        B      1\n        1  a        C      2\n        2  b        B      3\n        3  b        C      4\n        4  c        B      5\n        5  c        C      6\n\n        >>> df.melt(value_vars=\'A\')\n          variable value\n        0        A     a\n        1        A     b\n        2        A     c\n\n        >>> ps.melt(df, id_vars=[\'A\', \'B\'])\n           A  B variable  value\n        0  a  1        C      2\n        1  b  3        C      4\n        2  c  5        C      6\n\n        >>> df.melt(id_vars=[\'A\'], value_vars=[\'C\'])\n           A variable  value\n        0  a        C      2\n        1  b        C      4\n        2  c        C      6\n\n        The names of \'variable\' and \'value\' columns can be customized:\n\n        >>> ps.melt(df, id_vars=[\'A\'], value_vars=[\'B\'],\n        ...         var_name=\'myVarname\', value_name=\'myValname\')\n           A myVarname  myValname\n        0  a         B          1\n        1  b         B          3\n        2  c         B          5\n        '
    column_labels = self._internal.column_labels
    if (id_vars is None):
        id_vars = []
    else:
        if isinstance(id_vars, tuple):
            if (self._internal.column_labels_level == 1):
                id_vars = [(idv if is_name_like_tuple(idv) else (idv,)) for idv in id_vars]
            else:
                raise ValueError('id_vars must be a list of tuples when columns are a MultiIndex')
        elif is_name_like_value(id_vars):
            id_vars = [(id_vars,)]
        else:
            id_vars = [(idv if is_name_like_tuple(idv) else (idv,)) for idv in id_vars]
        non_existence_col = [idv for idv in id_vars if (idv not in column_labels)]
        if (len(non_existence_col) != 0):
            raveled_column_labels = np.ravel(column_labels)
            missing = [nec for nec in np.ravel(non_existence_col) if (nec not in raveled_column_labels)]
            if (len(missing) != 0):
                raise KeyError("The following 'id_vars' are not present in the DataFrame: {}".format(missing))
            else:
                raise KeyError('None of {} are in the {}'.format(non_existence_col, column_labels))
    if (value_vars is None):
        value_vars = []
    else:
        if isinstance(value_vars, tuple):
            if (self._internal.column_labels_level == 1):
                value_vars = [(valv if is_name_like_tuple(valv) else (valv,)) for valv in value_vars]
            else:
                raise ValueError('value_vars must be a list of tuples when columns are a MultiIndex')
        elif is_name_like_value(value_vars):
            value_vars = [(value_vars,)]
        else:
            value_vars = [(valv if is_name_like_tuple(valv) else (valv,)) for valv in value_vars]
        non_existence_col = [valv for valv in value_vars if (valv not in column_labels)]
        if (len(non_existence_col) != 0):
            raveled_column_labels = np.ravel(column_labels)
            missing = [nec for nec in np.ravel(non_existence_col) if (nec not in raveled_column_labels)]
            if (len(missing) != 0):
                raise KeyError("The following 'value_vars' are not present in the DataFrame: {}".format(missing))
            else:
                raise KeyError('None of {} are in the {}'.format(non_existence_col, column_labels))
    if (len(value_vars) == 0):
        value_vars = column_labels
    column_labels = [label for label in column_labels if (label not in id_vars)]
    sdf = self._internal.spark_frame
    if (var_name is None):
        if ((self._internal.column_labels_level == 1) and (self._internal.column_label_names[0] is None)):
            var_name = ['variable']
        else:
            var_name = [(name_like_string(name) if (name is not None) else 'variable_{}'.format(i)) for (i, name) in enumerate(self._internal.column_label_names)]
    elif isinstance(var_name, str):
        var_name = [var_name]
    pairs = F.explode(F.array(*[F.struct(*[SF.lit(c).alias(name) for (c, name) in zip(label, var_name)], *[self._internal.spark_column_for(label).alias(value_name)]) for label in column_labels if (label in value_vars)]))
    columns = (([self._internal.spark_column_for(label).alias(name_like_string(label)) for label in id_vars] + [F.col(('pairs.`%s`' % name)) for name in var_name]) + [F.col(('pairs.`%s`' % value_name))])
    exploded_df = sdf.withColumn('pairs', pairs).select(columns)
    return DataFrame(InternalFrame(spark_frame=exploded_df, index_spark_columns=None, column_labels=(([(label if (len(label) == 1) else (name_like_string(label),)) for label in id_vars] + [(name,) for name in var_name]) + [(value_name,)])))
Unpivot a DataFrame from wide format to long format, optionally
leaving identifier variables set.

This function is useful to massage a DataFrame into a format where one
or more columns are identifier variables (`id_vars`), while all other
columns, considered measured variables (`value_vars`), are "unpivoted" to
the row axis, leaving just two non-identifier columns, 'variable' and
'value'.

Parameters
----------
frame : DataFrame
id_vars : tuple, list, or ndarray, optional
    Column(s) to use as identifier variables.
value_vars : tuple, list, or ndarray, optional
    Column(s) to unpivot. If not specified, uses all columns that
    are not set as `id_vars`.
var_name : scalar, default 'variable'
    Name to use for the 'variable' column. If None it uses `frame.columns.name` or
    ‘variable’.
value_name : scalar, default 'value'
    Name to use for the 'value' column.

Returns
-------
DataFrame
    Unpivoted DataFrame.

Examples
--------
>>> df = ps.DataFrame({'A': {0: 'a', 1: 'b', 2: 'c'},
...                    'B': {0: 1, 1: 3, 2: 5},
...                    'C': {0: 2, 1: 4, 2: 6}},
...                   columns=['A', 'B', 'C'])
>>> df
   A  B  C
0  a  1  2
1  b  3  4
2  c  5  6

>>> ps.melt(df)
  variable value
0        A     a
1        B     1
2        C     2
3        A     b
4        B     3
5        C     4
6        A     c
7        B     5
8        C     6

>>> df.melt(id_vars='A')
   A variable  value
0  a        B      1
1  a        C      2
2  b        B      3
3  b        C      4
4  c        B      5
5  c        C      6

>>> df.melt(value_vars='A')
  variable value
0        A     a
1        A     b
2        A     c

>>> ps.melt(df, id_vars=['A', 'B'])
   A  B variable  value
0  a  1        C      2
1  b  3        C      4
2  c  5        C      6

>>> df.melt(id_vars=['A'], value_vars=['C'])
   A variable  value
0  a        C      2
1  b        C      4
2  c        C      6

The names of 'variable' and 'value' columns can be customized:

>>> ps.melt(df, id_vars=['A'], value_vars=['B'],
...         var_name='myVarname', value_name='myValname')
   A myVarname  myValname
0  a         B          1
1  b         B          3
2  c         B          5
def melt(self, id_vars: Optional[Union[(Name, List[Name])]]=None, value_vars: Optional[Union[(Name, List[Name])]]=None, var_name: Optional[Union[(str, List[str])]]=None, value_name: str='value') -> 'DataFrame':
    '\n        Unpivot a DataFrame from wide format to long format, optionally\n        leaving identifier variables set.\n\n        This function is useful to massage a DataFrame into a format where one\n        or more columns are identifier variables (`id_vars`), while all other\n        columns, considered measured variables (`value_vars`), are "unpivoted" to\n        the row axis, leaving just two non-identifier columns, \'variable\' and\n        \'value\'.\n\n        Parameters\n        ----------\n        frame : DataFrame\n        id_vars : tuple, list, or ndarray, optional\n            Column(s) to use as identifier variables.\n        value_vars : tuple, list, or ndarray, optional\n            Column(s) to unpivot. If not specified, uses all columns that\n            are not set as `id_vars`.\n        var_name : scalar, default \'variable\'\n            Name to use for the \'variable\' column. If None it uses `frame.columns.name` or\n            ‘variable’.\n        value_name : scalar, default \'value\'\n            Name to use for the \'value\' column.\n\n        Returns\n        -------\n        DataFrame\n            Unpivoted DataFrame.\n\n        Examples\n        --------\n        >>> df = ps.DataFrame({\'A\': {0: \'a\', 1: \'b\', 2: \'c\'},\n        ...                    \'B\': {0: 1, 1: 3, 2: 5},\n        ...                    \'C\': {0: 2, 1: 4, 2: 6}},\n        ...                   columns=[\'A\', \'B\', \'C\'])\n        >>> df\n           A  B  C\n        0  a  1  2\n        1  b  3  4\n        2  c  5  6\n\n        >>> ps.melt(df)\n          variable value\n        0        A     a\n        1        B     1\n        2        C     2\n        3        A     b\n        4        B     3\n        5        C     4\n        6        A     c\n        7        B     5\n        8        C     6\n\n        >>> df.melt(id_vars=\'A\')\n           A variable  value\n        0  a        B      1\n        1  a        C      2\n        2  b        B      3\n        3  b        C      4\n        4  c        B      5\n        5  c        C      6\n\n        >>> df.melt(value_vars=\'A\')\n          variable value\n        0        A     a\n        1        A     b\n        2        A     c\n\n        >>> ps.melt(df, id_vars=[\'A\', \'B\'])\n           A  B variable  value\n        0  a  1        C      2\n        1  b  3        C      4\n        2  c  5        C      6\n\n        >>> df.melt(id_vars=[\'A\'], value_vars=[\'C\'])\n           A variable  value\n        0  a        C      2\n        1  b        C      4\n        2  c        C      6\n\n        The names of \'variable\' and \'value\' columns can be customized:\n\n        >>> ps.melt(df, id_vars=[\'A\'], value_vars=[\'B\'],\n        ...         var_name=\'myVarname\', value_name=\'myValname\')\n           A myVarname  myValname\n        0  a         B          1\n        1  b         B          3\n        2  c         B          5\n        '
    column_labels = self._internal.column_labels
    if (id_vars is None):
        id_vars = []
    else:
        if isinstance(id_vars, tuple):
            if (self._internal.column_labels_level == 1):
                id_vars = [(idv if is_name_like_tuple(idv) else (idv,)) for idv in id_vars]
            else:
                raise ValueError('id_vars must be a list of tuples when columns are a MultiIndex')
        elif is_name_like_value(id_vars):
            id_vars = [(id_vars,)]
        else:
            id_vars = [(idv if is_name_like_tuple(idv) else (idv,)) for idv in id_vars]
        non_existence_col = [idv for idv in id_vars if (idv not in column_labels)]
        if (len(non_existence_col) != 0):
            raveled_column_labels = np.ravel(column_labels)
            missing = [nec for nec in np.ravel(non_existence_col) if (nec not in raveled_column_labels)]
            if (len(missing) != 0):
                raise KeyError("The following 'id_vars' are not present in the DataFrame: {}".format(missing))
            else:
                raise KeyError('None of {} are in the {}'.format(non_existence_col, column_labels))
    if (value_vars is None):
        value_vars = []
    else:
        if isinstance(value_vars, tuple):
            if (self._internal.column_labels_level == 1):
                value_vars = [(valv if is_name_like_tuple(valv) else (valv,)) for valv in value_vars]
            else:
                raise ValueError('value_vars must be a list of tuples when columns are a MultiIndex')
        elif is_name_like_value(value_vars):
            value_vars = [(value_vars,)]
        else:
            value_vars = [(valv if is_name_like_tuple(valv) else (valv,)) for valv in value_vars]
        non_existence_col = [valv for valv in value_vars if (valv not in column_labels)]
        if (len(non_existence_col) != 0):
            raveled_column_labels = np.ravel(column_labels)
            missing = [nec for nec in np.ravel(non_existence_col) if (nec not in raveled_column_labels)]
            if (len(missing) != 0):
                raise KeyError("The following 'value_vars' are not present in the DataFrame: {}".format(missing))
            else:
                raise KeyError('None of {} are in the {}'.format(non_existence_col, column_labels))
    if (len(value_vars) == 0):
        value_vars = column_labels
    column_labels = [label for label in column_labels if (label not in id_vars)]
    sdf = self._internal.spark_frame
    if (var_name is None):
        if ((self._internal.column_labels_level == 1) and (self._internal.column_label_names[0] is None)):
            var_name = ['variable']
        else:
            var_name = [(name_like_string(name) if (name is not None) else 'variable_{}'.format(i)) for (i, name) in enumerate(self._internal.column_label_names)]
    elif isinstance(var_name, str):
        var_name = [var_name]
    pairs = F.explode(F.array(*[F.struct(*[SF.lit(c).alias(name) for (c, name) in zip(label, var_name)], *[self._internal.spark_column_for(label).alias(value_name)]) for label in column_labels if (label in value_vars)]))
    columns = (([self._internal.spark_column_for(label).alias(name_like_string(label)) for label in id_vars] + [F.col(('pairs.`%s`' % name)) for name in var_name]) + [F.col(('pairs.`%s`' % value_name))])
    exploded_df = sdf.withColumn('pairs', pairs).select(columns)
    return DataFrame(InternalFrame(spark_frame=exploded_df, index_spark_columns=None, column_labels=(([(label if (len(label) == 1) else (name_like_string(label),)) for label in id_vars] + [(name,) for name in var_name]) + [(value_name,)])))