Skip to content

Commit 66f017c

Browse files
authored
Fixing pivot docs and example (#273)
Fixing pivot docs and example to close #272
1 parent bc24e12 commit 66f017c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

polars/dataframe.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ export interface DataFrame
931931
*/
932932
melt(idVars: ColumnSelection, valueVars: ColumnSelection): DataFrame;
933933
/**
934-
* Unpivot DataFrame to long format.
934+
* Unpivot a DataFrame from wide to long format.
935935
* ___
936936
*
937937
* @param idVars - Columns to use as identifier variables.
@@ -1029,9 +1029,15 @@ export interface DataFrame
10291029
/**
10301030
* Create a spreadsheet-style pivot table as a DataFrame.
10311031
*
1032-
* @param values Column values to aggregate. Can be multiple columns if the *columns* arguments contains multiple columns as well
1033-
* @param options.index One or multiple keys to group by
1034-
* @param options.columns Columns whose values will be used as the header of the output DataFrame
1032+
* @param values The existing column(s) of values which will be moved under the new columns from index. If an
1033+
* aggregation is specified, these are the values on which the aggregation will be computed.
1034+
* If None, all remaining columns not specified on `on` and `index` will be used.
1035+
* At least one of `index` and `values` must be specified.
1036+
* @param options.index The column(s) that remain from the input to the output. The output DataFrame will have one row
1037+
* for each unique combination of the `index`'s values.
1038+
* If None, all remaining columns not specified on `on` and `values` will be used. At least one
1039+
* of `index` and `values` must be specified.
1040+
* @param options.on The column(s) whose values will be used as the new columns of the output DataFrame.
10351041
* @param options.aggregateFunc
10361042
* Any of:
10371043
* - "sum"
@@ -1055,7 +1061,7 @@ export interface DataFrame
10551061
* ... "baz": [1, 2, 3, 4, 5, 6],
10561062
* ... }
10571063
* ... );
1058-
* > df.pivot("baz", {index:"foo", columns:"bar"});
1064+
* > df.pivot("baz", {index:"foo", on:"bar"});
10591065
* shape: (2, 4)
10601066
* ┌─────┬─────┬─────┬─────┐
10611067
* │ foo ┆ A ┆ B ┆ C │

0 commit comments

Comments
 (0)