xorbits.pandas.lreshape#
- xorbits.pandas.lreshape(data: DataFrame, groups, dropna: bool = True, label=None) DataFrame[source]#
Reshape wide-format data to long. Generalized inverse of DataFrame.pivot.
Accepts a dictionary,
groups, in which each key is a new column name and each value is a list of old column names that will be “melted” under the new column name as part of the reshape.- Parameters
data (DataFrame) – The wide-format DataFrame.
groups (dict) – {new_name : list_of_columns}.
dropna (bool, default True) – Do not include columns whose entries are all NaN.
label (None) –
Not used.
Deprecated since version 1.0.0.
- Returns
Reshaped DataFrame.
- Return type
See also
meltUnpivot a DataFrame from wide to long format, optionally leaving identifiers set.
pivotCreate a spreadsheet-style pivot table as a DataFrame.
DataFrame.pivotPivot without aggregation that can handle non-numeric data.
DataFrame.pivot_tableGeneralization of pivot that can handle duplicate values for one index/column pair.
DataFrame.unstackPivot based on the index values instead of a column.
wide_to_longWide panel to long format. Less flexible but more user-friendly than melt.
Examples
>>> data = pd.DataFrame({'hr1': [514, 573], 'hr2': [545, 526], ... 'team': ['Red Sox', 'Yankees'], ... 'year1': [2007, 2007], 'year2': [2008, 2008]}) >>> data hr1 hr2 team year1 year2 0 514 545 Red Sox 2007 2008 1 573 526 Yankees 2007 2008
>>> pd.lreshape(data, {'year': ['year1', 'year2'], 'hr': ['hr1', 'hr2']}) team year hr 0 Red Sox 2007 514 1 Yankees 2007 573 2 Red Sox 2008 545 3 Yankees 2008 526
This docstring was copied from pandas.