From 08aab5b3d618b31819e7526286efd8a860564b64 Mon Sep 17 00:00:00 2001 From: Justin Ma Date: Thu, 9 May 2024 17:45:07 +0800 Subject: [PATCH] Add docs for polars related commands (#1394) --- commands/docs/dfr_datepart.md | 10 +- commands/docs/from_ics.md | 11 +- commands/docs/from_msgpack.md | 2 +- commands/docs/histogram.md | 12 +- commands/docs/polars.md | 145 ++++++++++++++++++++++++ commands/docs/polars_agg-groups.md | 35 ++++++ commands/docs/polars_agg.md | 72 ++++++++++++ commands/docs/polars_all-false.md | 53 +++++++++ commands/docs/polars_all-true.md | 53 +++++++++ commands/docs/polars_append.md | 64 +++++++++++ commands/docs/polars_arg-max.md | 40 +++++++ commands/docs/polars_arg-min.md | 40 +++++++ commands/docs/polars_arg-sort.md | 65 +++++++++++ commands/docs/polars_arg-true.md | 40 +++++++ commands/docs/polars_arg-unique.md | 42 +++++++ commands/docs/polars_arg-where.md | 46 ++++++++ commands/docs/polars_as-date.md | 49 ++++++++ commands/docs/polars_as-datetime.md | 75 ++++++++++++ commands/docs/polars_as.md | 45 ++++++++ commands/docs/polars_cache.md | 35 ++++++ commands/docs/polars_cast.md | 58 ++++++++++ commands/docs/polars_col.md | 42 +++++++ commands/docs/polars_collect.md | 41 +++++++ commands/docs/polars_columns.md | 39 +++++++ commands/docs/polars_concat-str.md | 47 ++++++++ commands/docs/polars_concatenate.md | 47 ++++++++ commands/docs/polars_contains.md | 46 ++++++++ commands/docs/polars_count-null.md | 41 +++++++ commands/docs/polars_count.md | 35 ++++++ commands/docs/polars_cumulative.md | 52 +++++++++ commands/docs/polars_datepart.md | 62 ++++++++++ commands/docs/polars_drop-duplicates.md | 50 ++++++++ commands/docs/polars_drop-nulls.md | 63 ++++++++++ commands/docs/polars_drop.md | 45 ++++++++ commands/docs/polars_dummies.md | 60 ++++++++++ commands/docs/polars_explode.md | 61 ++++++++++ commands/docs/polars_expr-not.md | 35 ++++++ commands/docs/polars_fetch.md | 45 ++++++++ commands/docs/polars_fill-nan.md | 60 ++++++++++ commands/docs/polars_fill-null.md | 48 ++++++++ commands/docs/polars_filter-with.md | 56 +++++++++ commands/docs/polars_filter.md | 45 ++++++++ commands/docs/polars_first.md | 62 ++++++++++ commands/docs/polars_flatten.md | 61 ++++++++++ commands/docs/polars_get-day.md | 43 +++++++ commands/docs/polars_get-hour.md | 43 +++++++ commands/docs/polars_get-minute.md | 43 +++++++ commands/docs/polars_get-month.md | 43 +++++++ commands/docs/polars_get-nanosecond.md | 43 +++++++ commands/docs/polars_get-ordinal.md | 43 +++++++ commands/docs/polars_get-second.md | 43 +++++++ commands/docs/polars_get-week.md | 43 +++++++ commands/docs/polars_get-weekday.md | 43 +++++++ commands/docs/polars_get-year.md | 43 +++++++ commands/docs/polars_get.md | 45 ++++++++ commands/docs/polars_group-by.md | 72 ++++++++++++ commands/docs/polars_implode.md | 35 ++++++ commands/docs/polars_into-df.md | 113 ++++++++++++++++++ commands/docs/polars_into-lazy.md | 39 +++++++ commands/docs/polars_into-nu.md | 66 +++++++++++ commands/docs/polars_is-duplicated.md | 61 ++++++++++ commands/docs/polars_is-in.md | 65 +++++++++++ commands/docs/polars_is-not-null.md | 51 +++++++++ commands/docs/polars_is-null.md | 51 +++++++++ commands/docs/polars_is-unique.md | 61 ++++++++++ commands/docs/polars_join.md | 75 ++++++++++++ commands/docs/polars_last.md | 50 ++++++++ commands/docs/polars_lit.md | 42 +++++++ commands/docs/polars_lowercase.md | 42 +++++++ commands/docs/polars_max.md | 55 +++++++++ commands/docs/polars_mean.md | 55 +++++++++ commands/docs/polars_median.md | 55 +++++++++ commands/docs/polars_melt.md | 52 +++++++++ commands/docs/polars_min.md | 55 +++++++++ commands/docs/polars_n-unique.md | 46 ++++++++ commands/docs/polars_not.md | 42 +++++++ commands/docs/polars_open.md | 50 ++++++++ commands/docs/polars_otherwise.md | 66 +++++++++++ commands/docs/polars_quantile.md | 59 ++++++++++ commands/docs/polars_query.md | 45 ++++++++ commands/docs/polars_rename.md | 72 ++++++++++++ commands/docs/polars_replace-all.md | 47 ++++++++ commands/docs/polars_replace.md | 47 ++++++++ commands/docs/polars_reverse.md | 42 +++++++ commands/docs/polars_rolling.md | 62 ++++++++++ commands/docs/polars_sample.md | 49 ++++++++ commands/docs/polars_schema.md | 42 +++++++ commands/docs/polars_select.md | 46 ++++++++ commands/docs/polars_set-with-idx.md | 55 +++++++++ commands/docs/polars_set.md | 54 +++++++++ commands/docs/polars_shape.md | 40 +++++++ commands/docs/polars_shift.md | 50 ++++++++ commands/docs/polars_slice.md | 45 ++++++++ commands/docs/polars_sort-by.md | 66 +++++++++++ commands/docs/polars_std.md | 55 +++++++++ commands/docs/polars_store-get.md | 46 ++++++++ commands/docs/polars_store-ls.md | 36 ++++++ commands/docs/polars_store-rm.md | 40 +++++++ commands/docs/polars_str-lengths.md | 42 +++++++ commands/docs/polars_str-slice.md | 63 ++++++++++ commands/docs/polars_strftime.md | 47 ++++++++ commands/docs/polars_sum.md | 55 +++++++++ commands/docs/polars_summary.md | 53 +++++++++ commands/docs/polars_take.md | 61 ++++++++++ commands/docs/polars_to-arrow.md | 39 +++++++ commands/docs/polars_to-avro.md | 43 +++++++ commands/docs/polars_to-csv.md | 50 ++++++++ commands/docs/polars_to-jsonl.md | 39 +++++++ commands/docs/polars_to-parquet.md | 39 +++++++ commands/docs/polars_unique.md | 79 +++++++++++++ commands/docs/polars_uppercase.md | 42 +++++++ commands/docs/polars_value-counts.md | 41 +++++++ commands/docs/polars_var.md | 55 +++++++++ commands/docs/polars_when.md | 67 +++++++++++ commands/docs/polars_with-column.md | 69 +++++++++++ commands/docs/update_cells.md | 20 ++-- 116 files changed, 5783 insertions(+), 28 deletions(-) create mode 100644 commands/docs/polars.md create mode 100644 commands/docs/polars_agg-groups.md create mode 100644 commands/docs/polars_agg.md create mode 100644 commands/docs/polars_all-false.md create mode 100644 commands/docs/polars_all-true.md create mode 100644 commands/docs/polars_append.md create mode 100644 commands/docs/polars_arg-max.md create mode 100644 commands/docs/polars_arg-min.md create mode 100644 commands/docs/polars_arg-sort.md create mode 100644 commands/docs/polars_arg-true.md create mode 100644 commands/docs/polars_arg-unique.md create mode 100644 commands/docs/polars_arg-where.md create mode 100644 commands/docs/polars_as-date.md create mode 100644 commands/docs/polars_as-datetime.md create mode 100644 commands/docs/polars_as.md create mode 100644 commands/docs/polars_cache.md create mode 100644 commands/docs/polars_cast.md create mode 100644 commands/docs/polars_col.md create mode 100644 commands/docs/polars_collect.md create mode 100644 commands/docs/polars_columns.md create mode 100644 commands/docs/polars_concat-str.md create mode 100644 commands/docs/polars_concatenate.md create mode 100644 commands/docs/polars_contains.md create mode 100644 commands/docs/polars_count-null.md create mode 100644 commands/docs/polars_count.md create mode 100644 commands/docs/polars_cumulative.md create mode 100644 commands/docs/polars_datepart.md create mode 100644 commands/docs/polars_drop-duplicates.md create mode 100644 commands/docs/polars_drop-nulls.md create mode 100644 commands/docs/polars_drop.md create mode 100644 commands/docs/polars_dummies.md create mode 100644 commands/docs/polars_explode.md create mode 100644 commands/docs/polars_expr-not.md create mode 100644 commands/docs/polars_fetch.md create mode 100644 commands/docs/polars_fill-nan.md create mode 100644 commands/docs/polars_fill-null.md create mode 100644 commands/docs/polars_filter-with.md create mode 100644 commands/docs/polars_filter.md create mode 100644 commands/docs/polars_first.md create mode 100644 commands/docs/polars_flatten.md create mode 100644 commands/docs/polars_get-day.md create mode 100644 commands/docs/polars_get-hour.md create mode 100644 commands/docs/polars_get-minute.md create mode 100644 commands/docs/polars_get-month.md create mode 100644 commands/docs/polars_get-nanosecond.md create mode 100644 commands/docs/polars_get-ordinal.md create mode 100644 commands/docs/polars_get-second.md create mode 100644 commands/docs/polars_get-week.md create mode 100644 commands/docs/polars_get-weekday.md create mode 100644 commands/docs/polars_get-year.md create mode 100644 commands/docs/polars_get.md create mode 100644 commands/docs/polars_group-by.md create mode 100644 commands/docs/polars_implode.md create mode 100644 commands/docs/polars_into-df.md create mode 100644 commands/docs/polars_into-lazy.md create mode 100644 commands/docs/polars_into-nu.md create mode 100644 commands/docs/polars_is-duplicated.md create mode 100644 commands/docs/polars_is-in.md create mode 100644 commands/docs/polars_is-not-null.md create mode 100644 commands/docs/polars_is-null.md create mode 100644 commands/docs/polars_is-unique.md create mode 100644 commands/docs/polars_join.md create mode 100644 commands/docs/polars_last.md create mode 100644 commands/docs/polars_lit.md create mode 100644 commands/docs/polars_lowercase.md create mode 100644 commands/docs/polars_max.md create mode 100644 commands/docs/polars_mean.md create mode 100644 commands/docs/polars_median.md create mode 100644 commands/docs/polars_melt.md create mode 100644 commands/docs/polars_min.md create mode 100644 commands/docs/polars_n-unique.md create mode 100644 commands/docs/polars_not.md create mode 100644 commands/docs/polars_open.md create mode 100644 commands/docs/polars_otherwise.md create mode 100644 commands/docs/polars_quantile.md create mode 100644 commands/docs/polars_query.md create mode 100644 commands/docs/polars_rename.md create mode 100644 commands/docs/polars_replace-all.md create mode 100644 commands/docs/polars_replace.md create mode 100644 commands/docs/polars_reverse.md create mode 100644 commands/docs/polars_rolling.md create mode 100644 commands/docs/polars_sample.md create mode 100644 commands/docs/polars_schema.md create mode 100644 commands/docs/polars_select.md create mode 100644 commands/docs/polars_set-with-idx.md create mode 100644 commands/docs/polars_set.md create mode 100644 commands/docs/polars_shape.md create mode 100644 commands/docs/polars_shift.md create mode 100644 commands/docs/polars_slice.md create mode 100644 commands/docs/polars_sort-by.md create mode 100644 commands/docs/polars_std.md create mode 100644 commands/docs/polars_store-get.md create mode 100644 commands/docs/polars_store-ls.md create mode 100644 commands/docs/polars_store-rm.md create mode 100644 commands/docs/polars_str-lengths.md create mode 100644 commands/docs/polars_str-slice.md create mode 100644 commands/docs/polars_strftime.md create mode 100644 commands/docs/polars_sum.md create mode 100644 commands/docs/polars_summary.md create mode 100644 commands/docs/polars_take.md create mode 100644 commands/docs/polars_to-arrow.md create mode 100644 commands/docs/polars_to-avro.md create mode 100644 commands/docs/polars_to-csv.md create mode 100644 commands/docs/polars_to-jsonl.md create mode 100644 commands/docs/polars_to-parquet.md create mode 100644 commands/docs/polars_unique.md create mode 100644 commands/docs/polars_uppercase.md create mode 100644 commands/docs/polars_value-counts.md create mode 100644 commands/docs/polars_var.md create mode 100644 commands/docs/polars_when.md create mode 100644 commands/docs/polars_with-column.md diff --git a/commands/docs/dfr_datepart.md b/commands/docs/dfr_datepart.md index ee72d1e1ec..30b00e2b9f 100644 --- a/commands/docs/dfr_datepart.md +++ b/commands/docs/dfr_datepart.md @@ -57,10 +57,10 @@ Creates an expression to capture multiple date parts (dfr col datetime | dfr datepart minute | dfr as datetime_minute ), (dfr col datetime | dfr datepart second | dfr as datetime_second ), (dfr col datetime | dfr datepart nanosecond | dfr as datetime_ns ) ] -╭─────┬───────────────┬─────────────────┬──────────────────┬───────────────┬────────────────┬──────────────────┬──────╮ -│ # │ datetime │ datetime_year │ datetime_month │ datetime_day │ datetime_hour │ datetime_minute │ ... │ -├─────┼───────────────┼─────────────────┼──────────────────┼───────────────┼────────────────┼──────────────────┼──────┤ -│ 0 │ 2 years ago │ 2021 │ 12 │ 30 │ 1 │ 2 │ ... │ -╰─────┴───────────────┴─────────────────┴──────────────────┴───────────────┴────────────────┴──────────────────┴──────╯ +╭───┬─────────────┬───────────────┬────────────────┬──────────────┬───────────────┬─────────────────┬─────────────────┬─────────────╮ +│ # │ datetime │ datetime_year │ datetime_month │ datetime_day │ datetime_hour │ datetime_minute │ datetime_second │ datetime_ns │ +├───┼─────────────┼───────────────┼────────────────┼──────────────┼───────────────┼─────────────────┼─────────────────┼─────────────┤ +│ 0 │ 2 years ago │ 2021 │ 12 │ 30 │ 1 │ 2 │ 3 │ 123456789 │ +╰───┴─────────────┴───────────────┴────────────────┴──────────────┴───────────────┴─────────────────┴─────────────────┴─────────────╯ ``` diff --git a/commands/docs/from_ics.md b/commands/docs/from_ics.md index 35a3c40b29..3827fcfa66 100644 --- a/commands/docs/from_ics.md +++ b/commands/docs/from_ics.md @@ -36,11 +36,10 @@ Converts ics formatted string to table ```nu > 'BEGIN:VCALENDAR END:VCALENDAR' | from ics -╭───┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬───────────╮ -│ # │ properties │ events │ alarms │ to-Dos │ journals │ free-busys │ timezones │ -├───┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼───────────┤ -│ 0 │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 │ -│ │ │ │ │ │ │ │ items] │ -╰───┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴───────────╯ +╭───┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────┬────────────────╮ +│ # │ properties │ events │ alarms │ to-Dos │ journals │ free-busys │ timezones │ +├───┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┼────────────────┤ +│ 0 │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ [list 0 items] │ +╰───┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────┴────────────────╯ ``` diff --git a/commands/docs/from_msgpack.md b/commands/docs/from_msgpack.md index 95f19d87e1..fee6cc91f7 100644 --- a/commands/docs/from_msgpack.md +++ b/commands/docs/from_msgpack.md @@ -62,7 +62,7 @@ Read a table from MessagePack │ # │ event_name │ time │ ├───┼──────────────────────┼──────────────┤ │ 0 │ Apollo 11 Landing │ 54 years ago │ -│ 1 │ Nushell first commit │ 4 years ago │ +│ 1 │ Nushell first commit │ 5 years ago │ ╰───┴──────────────────────┴──────────────╯ ``` diff --git a/commands/docs/histogram.md b/commands/docs/histogram.md index 5aae5121a8..db26c65901 100644 --- a/commands/docs/histogram.md +++ b/commands/docs/histogram.md @@ -52,12 +52,12 @@ Compute a histogram for the types of files, with frequency column named freq Compute a histogram for a list of numbers ```nu > [1 2 1] | histogram -╭────┬────────┬────────┬───────────┬─────────────┬────────────────────────────────────────────────────────────────────╮ -│ # │ value │ count │ quantile │ percentage │ frequency │ -├────┼────────┼────────┼───────────┼─────────────┼────────────────────────────────────────────────────────────────────┤ -│ 0 │ 1 │ 2 │ 0.67 │ 66.67% │ ****************************************************************** │ -│ 1 │ 2 │ 1 │ 0.33 │ 33.33% │ ********************************* │ -╰────┴────────┴────────┴───────────┴─────────────┴────────────────────────────────────────────────────────────────────╯ +╭───┬───────┬───────┬──────────┬────────────┬────────────────────────────────────────────────────────────────────╮ +│ # │ value │ count │ quantile │ percentage │ frequency │ +├───┼───────┼───────┼──────────┼────────────┼────────────────────────────────────────────────────────────────────┤ +│ 0 │ 1 │ 2 │ 0.67 │ 66.67% │ ****************************************************************** │ +│ 1 │ 2 │ 1 │ 0.33 │ 33.33% │ ********************************* │ +╰───┴───────┴───────┴──────────┴────────────┴────────────────────────────────────────────────────────────────────╯ ``` diff --git a/commands/docs/polars.md b/commands/docs/polars.md new file mode 100644 index 0000000000..d19d3282ac --- /dev/null +++ b/commands/docs/polars.md @@ -0,0 +1,145 @@ +--- +title: polars +categories: | + dataframe +version: 0.93.0 +dataframe: | + Operate with data in a dataframe format. +usage: | + Operate with data in a dataframe format. +feature: default +--- + + +# `polars` for [dataframe](/commands/categories/dataframe.md) + +
Operate with data in a dataframe format.
+ +## Signature + +```> polars {flags} ``` + + +## Input/output types: + +| input | output | +| ------- | ------ | +| nothing | string | + +## Notes +You must use one of the following subcommands. Using this command as-is will only produce this help message. + +## Subcommands: + +| name | type | usage | +| -------------------------------------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------ | +| [`polars agg`](/commands/docs/polars_agg.md) | Builtin,Plugin | Performs a series of aggregations from a group-by. | +| [`polars agg-groups`](/commands/docs/polars_agg-groups.md) | Builtin,Plugin | Creates an agg_groups expression. | +| [`polars all-false`](/commands/docs/polars_all-false.md) | Builtin,Plugin | Returns true if all values are false. | +| [`polars all-true`](/commands/docs/polars_all-true.md) | Builtin,Plugin | Returns true if all values are true. | +| [`polars append`](/commands/docs/polars_append.md) | Builtin,Plugin | Appends a new dataframe. | +| [`polars arg-max`](/commands/docs/polars_arg-max.md) | Builtin,Plugin | Return index for max value in series. | +| [`polars arg-min`](/commands/docs/polars_arg-min.md) | Builtin,Plugin | Return index for min value in series. | +| [`polars arg-sort`](/commands/docs/polars_arg-sort.md) | Builtin,Plugin | Returns indexes for a sorted series. | +| [`polars arg-true`](/commands/docs/polars_arg-true.md) | Builtin,Plugin | Returns indexes where values are true. | +| [`polars arg-unique`](/commands/docs/polars_arg-unique.md) | Builtin,Plugin | Returns indexes for unique values. | +| [`polars arg-where`](/commands/docs/polars_arg-where.md) | Builtin,Plugin | Creates an expression that returns the arguments where expression is true. | +| [`polars as`](/commands/docs/polars_as.md) | Builtin,Plugin | Creates an alias expression. | +| [`polars as-date`](/commands/docs/polars_as-date.md) | Builtin,Plugin | Converts string to date. | +| [`polars as-datetime`](/commands/docs/polars_as-datetime.md) | Builtin,Plugin | Converts string to datetime. | +| [`polars cache`](/commands/docs/polars_cache.md) | Builtin,Plugin | Caches operations in a new LazyFrame. | +| [`polars cast`](/commands/docs/polars_cast.md) | Builtin,Plugin | Cast a column to a different dtype. | +| [`polars col`](/commands/docs/polars_col.md) | Builtin,Plugin | Creates a named column expression. | +| [`polars collect`](/commands/docs/polars_collect.md) | Builtin,Plugin | Collect lazy dataframe into eager dataframe. | +| [`polars columns`](/commands/docs/polars_columns.md) | Builtin,Plugin | Show dataframe columns. | +| [`polars concat-str`](/commands/docs/polars_concat-str.md) | Builtin,Plugin | Creates a concat string expression. | +| [`polars concatenate`](/commands/docs/polars_concatenate.md) | Builtin,Plugin | Concatenates strings with other array. | +| [`polars contains`](/commands/docs/polars_contains.md) | Builtin,Plugin | Checks if a pattern is contained in a string. | +| [`polars count`](/commands/docs/polars_count.md) | Builtin,Plugin | Creates a count expression. | +| [`polars count-null`](/commands/docs/polars_count-null.md) | Builtin,Plugin | Counts null values. | +| [`polars cumulative`](/commands/docs/polars_cumulative.md) | Builtin,Plugin | Cumulative calculation for a series. | +| [`polars datepart`](/commands/docs/polars_datepart.md) | Builtin,Plugin | Creates an expression for capturing the specified datepart in a column. | +| [`polars drop`](/commands/docs/polars_drop.md) | Builtin,Plugin | Creates a new dataframe by dropping the selected columns. | +| [`polars drop-duplicates`](/commands/docs/polars_drop-duplicates.md) | Builtin,Plugin | Drops duplicate values in dataframe. | +| [`polars drop-nulls`](/commands/docs/polars_drop-nulls.md) | Builtin,Plugin | Drops null values in dataframe. | +| [`polars dummies`](/commands/docs/polars_dummies.md) | Builtin,Plugin | Creates a new dataframe with dummy variables. | +| [`polars explode`](/commands/docs/polars_explode.md) | Builtin,Plugin | Explodes a dataframe or creates a explode expression. | +| [`polars expr-not`](/commands/docs/polars_expr-not.md) | Builtin,Plugin | Creates a not expression. | +| [`polars fetch`](/commands/docs/polars_fetch.md) | Builtin,Plugin | Collects the lazyframe to the selected rows. | +| [`polars fill-nan`](/commands/docs/polars_fill-nan.md) | Builtin,Plugin | Replaces NaN values with the given expression. | +| [`polars fill-null`](/commands/docs/polars_fill-null.md) | Builtin,Plugin | Replaces NULL values with the given expression. | +| [`polars filter`](/commands/docs/polars_filter.md) | Builtin,Plugin | Filter dataframe based in expression. | +| [`polars filter-with`](/commands/docs/polars_filter-with.md) | Builtin,Plugin | Filters dataframe using a mask or expression as reference. | +| [`polars first`](/commands/docs/polars_first.md) | Builtin,Plugin | Show only the first number of rows or create a first expression | +| [`polars flatten`](/commands/docs/polars_flatten.md) | Builtin,Plugin | An alias for polars explode. | +| [`polars get`](/commands/docs/polars_get.md) | Builtin,Plugin | Creates dataframe with the selected columns. | +| [`polars get-day`](/commands/docs/polars_get-day.md) | Builtin,Plugin | Gets day from date. | +| [`polars get-hour`](/commands/docs/polars_get-hour.md) | Builtin,Plugin | Gets hour from date. | +| [`polars get-minute`](/commands/docs/polars_get-minute.md) | Builtin,Plugin | Gets minute from date. | +| [`polars get-month`](/commands/docs/polars_get-month.md) | Builtin,Plugin | Gets month from date. | +| [`polars get-nanosecond`](/commands/docs/polars_get-nanosecond.md) | Builtin,Plugin | Gets nanosecond from date. | +| [`polars get-ordinal`](/commands/docs/polars_get-ordinal.md) | Builtin,Plugin | Gets ordinal from date. | +| [`polars get-second`](/commands/docs/polars_get-second.md) | Builtin,Plugin | Gets second from date. | +| [`polars get-week`](/commands/docs/polars_get-week.md) | Builtin,Plugin | Gets week from date. | +| [`polars get-weekday`](/commands/docs/polars_get-weekday.md) | Builtin,Plugin | Gets weekday from date. | +| [`polars get-year`](/commands/docs/polars_get-year.md) | Builtin,Plugin | Gets year from date. | +| [`polars group-by`](/commands/docs/polars_group-by.md) | Builtin,Plugin | Creates a group-by object that can be used for other aggregations. | +| [`polars implode`](/commands/docs/polars_implode.md) | Builtin,Plugin | Aggregates a group to a Series. | +| [`polars into-df`](/commands/docs/polars_into-df.md) | Builtin,Plugin | Converts a list, table or record into a dataframe. | +| [`polars into-lazy`](/commands/docs/polars_into-lazy.md) | Builtin,Plugin | Converts a dataframe into a lazy dataframe. | +| [`polars into-nu`](/commands/docs/polars_into-nu.md) | Builtin,Plugin | Converts a dataframe or an expression into into nushell value for access and exploration. | +| [`polars is-duplicated`](/commands/docs/polars_is-duplicated.md) | Builtin,Plugin | Creates mask indicating duplicated values. | +| [`polars is-in`](/commands/docs/polars_is-in.md) | Builtin,Plugin | Creates an is-in expression or checks to see if the elements are contained in the right series | +| [`polars is-not-null`](/commands/docs/polars_is-not-null.md) | Builtin,Plugin | Creates mask where value is not null. | +| [`polars is-null`](/commands/docs/polars_is-null.md) | Builtin,Plugin | Creates mask where value is null. | +| [`polars is-unique`](/commands/docs/polars_is-unique.md) | Builtin,Plugin | Creates mask indicating unique values. | +| [`polars join`](/commands/docs/polars_join.md) | Builtin,Plugin | Joins a lazy frame with other lazy frame. | +| [`polars last`](/commands/docs/polars_last.md) | Builtin,Plugin | Creates new dataframe with tail rows or creates a last expression. | +| [`polars lit`](/commands/docs/polars_lit.md) | Builtin,Plugin | Creates a literal expression. | +| [`polars lowercase`](/commands/docs/polars_lowercase.md) | Builtin,Plugin | Lowercase the strings in the column. | +| [`polars max`](/commands/docs/polars_max.md) | Builtin,Plugin | Creates a max expression or aggregates columns to their max value. | +| [`polars mean`](/commands/docs/polars_mean.md) | Builtin,Plugin | Creates a mean expression for an aggregation or aggregates columns to their mean value. | +| [`polars median`](/commands/docs/polars_median.md) | Builtin,Plugin | Median value from columns in a dataframe or creates expression for an aggregation | +| [`polars melt`](/commands/docs/polars_melt.md) | Builtin,Plugin | Unpivot a DataFrame from wide to long format. | +| [`polars min`](/commands/docs/polars_min.md) | Builtin,Plugin | Creates a min expression or aggregates columns to their min value. | +| [`polars n-unique`](/commands/docs/polars_n-unique.md) | Builtin,Plugin | Counts unique values. | +| [`polars not`](/commands/docs/polars_not.md) | Builtin,Plugin | Inverts boolean mask. | +| [`polars open`](/commands/docs/polars_open.md) | Builtin,Plugin | Opens CSV, JSON, JSON lines, arrow, avro, or parquet file to create dataframe. | +| [`polars otherwise`](/commands/docs/polars_otherwise.md) | Builtin,Plugin | Completes a when expression. | +| [`polars quantile`](/commands/docs/polars_quantile.md) | Builtin,Plugin | Aggregates the columns to the selected quantile. | +| [`polars query`](/commands/docs/polars_query.md) | Builtin,Plugin | Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause. | +| [`polars rename`](/commands/docs/polars_rename.md) | Builtin,Plugin | Rename a dataframe column. | +| [`polars replace`](/commands/docs/polars_replace.md) | Builtin,Plugin | Replace the leftmost (sub)string by a regex pattern. | +| [`polars replace-all`](/commands/docs/polars_replace-all.md) | Builtin,Plugin | Replace all (sub)strings by a regex pattern. | +| [`polars reverse`](/commands/docs/polars_reverse.md) | Builtin,Plugin | Reverses the LazyFrame | +| [`polars rolling`](/commands/docs/polars_rolling.md) | Builtin,Plugin | Rolling calculation for a series. | +| [`polars sample`](/commands/docs/polars_sample.md) | Builtin,Plugin | Create sample dataframe. | +| [`polars schema`](/commands/docs/polars_schema.md) | Builtin,Plugin | Show schema for a dataframe. | +| [`polars select`](/commands/docs/polars_select.md) | Builtin,Plugin | Selects columns from lazyframe. | +| [`polars set`](/commands/docs/polars_set.md) | Builtin,Plugin | Sets value where given mask is true. | +| [`polars set-with-idx`](/commands/docs/polars_set-with-idx.md) | Builtin,Plugin | Sets value in the given index. | +| [`polars shape`](/commands/docs/polars_shape.md) | Builtin,Plugin | Shows column and row size for a dataframe. | +| [`polars shift`](/commands/docs/polars_shift.md) | Builtin,Plugin | Shifts the values by a given period. | +| [`polars slice`](/commands/docs/polars_slice.md) | Builtin,Plugin | Creates new dataframe from a slice of rows. | +| [`polars sort-by`](/commands/docs/polars_sort-by.md) | Builtin,Plugin | Sorts a lazy dataframe based on expression(s). | +| [`polars std`](/commands/docs/polars_std.md) | Builtin,Plugin | Creates a std expression for an aggregation of std value from columns in a dataframe. | +| [`polars store-get`](/commands/docs/polars_store-get.md) | Builtin,Plugin | Gets a Dataframe or other object from the plugin cache. | +| [`polars store-ls`](/commands/docs/polars_store-ls.md) | Builtin,Plugin | Lists stored dataframes. | +| [`polars store-rm`](/commands/docs/polars_store-rm.md) | Builtin,Plugin | Removes a stored Dataframe or other object from the plugin cache. | +| [`polars str-lengths`](/commands/docs/polars_str-lengths.md) | Builtin,Plugin | Get lengths of all strings. | +| [`polars str-slice`](/commands/docs/polars_str-slice.md) | Builtin,Plugin | Slices the string from the start position until the selected length. | +| [`polars strftime`](/commands/docs/polars_strftime.md) | Builtin,Plugin | Formats date based on string rule. | +| [`polars sum`](/commands/docs/polars_sum.md) | Builtin,Plugin | Creates a sum expression for an aggregation or aggregates columns to their sum value. | +| [`polars summary`](/commands/docs/polars_summary.md) | Builtin,Plugin | For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns. | +| [`polars take`](/commands/docs/polars_take.md) | Builtin,Plugin | Creates new dataframe using the given indices. | +| [`polars to-arrow`](/commands/docs/polars_to-arrow.md) | Builtin,Plugin | Saves dataframe to arrow file. | +| [`polars to-avro`](/commands/docs/polars_to-avro.md) | Builtin,Plugin | Saves dataframe to avro file. | +| [`polars to-csv`](/commands/docs/polars_to-csv.md) | Builtin,Plugin | Saves dataframe to CSV file. | +| [`polars to-jsonl`](/commands/docs/polars_to-jsonl.md) | Builtin,Plugin | Saves dataframe to a JSON lines file. | +| [`polars to-parquet`](/commands/docs/polars_to-parquet.md) | Builtin,Plugin | Saves dataframe to parquet file. | +| [`polars unique`](/commands/docs/polars_unique.md) | Builtin,Plugin | Returns unique values from a dataframe. | +| [`polars uppercase`](/commands/docs/polars_uppercase.md) | Builtin,Plugin | Uppercase the strings in the column. | +| [`polars value-counts`](/commands/docs/polars_value-counts.md) | Builtin,Plugin | Returns a dataframe with the counts for unique values in series. | +| [`polars var`](/commands/docs/polars_var.md) | Builtin,Plugin | Create a var expression for an aggregation. | +| [`polars when`](/commands/docs/polars_when.md) | Builtin,Plugin | Creates and modifies a when expression. | +| [`polars with-column`](/commands/docs/polars_with-column.md) | Builtin,Plugin | Adds a series to the dataframe. | \ No newline at end of file diff --git a/commands/docs/polars_agg-groups.md b/commands/docs/polars_agg-groups.md new file mode 100644 index 0000000000..cfdc3554b0 --- /dev/null +++ b/commands/docs/polars_agg-groups.md @@ -0,0 +1,35 @@ +--- +title: polars agg-groups +categories: | + expression +version: 0.93.0 +expression: | + Creates an agg_groups expression. +usage: | + Creates an agg_groups expression. +feature: default +--- + + +# `polars agg-groups` for [expression](/commands/categories/expression.md) + +
Creates an agg_groups expression.
+ +## Signature + +```> polars agg-groups {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + + +```nu +> + +``` diff --git a/commands/docs/polars_agg.md b/commands/docs/polars_agg.md new file mode 100644 index 0000000000..f834dd406f --- /dev/null +++ b/commands/docs/polars_agg.md @@ -0,0 +1,72 @@ +--- +title: polars agg +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Performs a series of aggregations from a group-by. +usage: | + Performs a series of aggregations from a group-by. +feature: default +--- + + +# `polars agg` for [lazyframe](/commands/categories/lazyframe.md) + +
Performs a series of aggregations from a group-by.
+ +## Signature + +```> polars agg {flags} ...rest``` + +## Parameters + + - `...rest`: Expression(s) that define the aggregations to be applied + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Group by and perform an aggregation +```nu +> [[a b]; [1 2] [1 4] [2 6] [2 4]] + | polars into-df + | polars group-by a + | polars agg [ + (polars col b | polars min | polars as "b_min") + (polars col b | polars max | polars as "b_max") + (polars col b | polars sum | polars as "b_sum") + ] +╭───┬───┬───────┬───────┬───────╮ +│ # │ a │ b_min │ b_max │ b_sum │ +├───┼───┼───────┼───────┼───────┤ +│ 0 │ 1 │ 2 │ 4 │ 6 │ +│ 1 │ 2 │ 4 │ 6 │ 10 │ +╰───┴───┴───────┴───────┴───────╯ + +``` + +Group by and perform an aggregation +```nu +> [[a b]; [1 2] [1 4] [2 6] [2 4]] + | polars into-lazy + | polars group-by a + | polars agg [ + (polars col b | polars min | polars as "b_min") + (polars col b | polars max | polars as "b_max") + (polars col b | polars sum | polars as "b_sum") + ] + | polars collect +╭───┬───┬───────┬───────┬───────╮ +│ # │ a │ b_min │ b_max │ b_sum │ +├───┼───┼───────┼───────┼───────┤ +│ 0 │ 1 │ 2 │ 4 │ 6 │ +│ 1 │ 2 │ 4 │ 6 │ 10 │ +╰───┴───┴───────┴───────┴───────╯ + +``` diff --git a/commands/docs/polars_all-false.md b/commands/docs/polars_all-false.md new file mode 100644 index 0000000000..654a241d29 --- /dev/null +++ b/commands/docs/polars_all-false.md @@ -0,0 +1,53 @@ +--- +title: polars all-false +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns true if all values are false. +usage: | + Returns true if all values are false. +feature: default +--- + + +# `polars all-false` for [dataframe](/commands/categories/dataframe.md) + +
Returns true if all values are false.
+ +## Signature + +```> polars all-false {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns true if all values are false +```nu +> [false false false] | polars into-df | polars all-false +╭───┬───────────╮ +│ # │ all_false │ +├───┼───────────┤ +│ 0 │ true │ +╰───┴───────────╯ + +``` + +Checks the result from a comparison +```nu +> let s = ([5 6 2 10] | polars into-df); + let res = ($s > 9); + $res | polars all-false +╭───┬───────────╮ +│ # │ all_false │ +├───┼───────────┤ +│ 0 │ false │ +╰───┴───────────╯ + +``` diff --git a/commands/docs/polars_all-true.md b/commands/docs/polars_all-true.md new file mode 100644 index 0000000000..680e59d03d --- /dev/null +++ b/commands/docs/polars_all-true.md @@ -0,0 +1,53 @@ +--- +title: polars all-true +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns true if all values are true. +usage: | + Returns true if all values are true. +feature: default +--- + + +# `polars all-true` for [dataframe](/commands/categories/dataframe.md) + +
Returns true if all values are true.
+ +## Signature + +```> polars all-true {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns true if all values are true +```nu +> [true true true] | polars into-df | polars all-true +╭───┬──────────╮ +│ # │ all_true │ +├───┼──────────┤ +│ 0 │ true │ +╰───┴──────────╯ + +``` + +Checks the result from a comparison +```nu +> let s = ([5 6 2 8] | polars into-df); + let res = ($s > 9); + $res | polars all-true +╭───┬──────────╮ +│ # │ all_true │ +├───┼──────────┤ +│ 0 │ false │ +╰───┴──────────╯ + +``` diff --git a/commands/docs/polars_append.md b/commands/docs/polars_append.md new file mode 100644 index 0000000000..d5f07c6135 --- /dev/null +++ b/commands/docs/polars_append.md @@ -0,0 +1,64 @@ +--- +title: polars append +categories: | + dataframe +version: 0.93.0 +dataframe: | + Appends a new dataframe. +usage: | + Appends a new dataframe. +feature: default +--- + + +# `polars append` for [dataframe](/commands/categories/dataframe.md) + +
Appends a new dataframe.
+ +## Signature + +```> polars append {flags} (other)``` + +## Flags + + - `--col, -c`: append as new columns instead of rows + +## Parameters + + - `other`: other dataframe to append + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Appends a dataframe as new columns +```nu +> let a = ([[a b]; [1 2] [3 4]] | polars into-df); + $a | polars append $a +╭───┬───┬───┬─────┬─────╮ +│ # │ a │ b │ a_x │ b_x │ +├───┼───┼───┼─────┼─────┤ +│ 0 │ 1 │ 2 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ 3 │ 4 │ +╰───┴───┴───┴─────┴─────╯ + +``` + +Appends a dataframe merging at the end of columns +```nu +> let a = ([[a b]; [1 2] [3 4]] | polars into-df); $a | polars append $a --col +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +│ 2 │ 1 │ 2 │ +│ 3 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_arg-max.md b/commands/docs/polars_arg-max.md new file mode 100644 index 0000000000..ac798838f4 --- /dev/null +++ b/commands/docs/polars_arg-max.md @@ -0,0 +1,40 @@ +--- +title: polars arg-max +categories: | + dataframe +version: 0.93.0 +dataframe: | + Return index for max value in series. +usage: | + Return index for max value in series. +feature: default +--- + + +# `polars arg-max` for [dataframe](/commands/categories/dataframe.md) + +
Return index for max value in series.
+ +## Signature + +```> polars arg-max {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns index for max value +```nu +> [1 3 2] | polars into-df | polars arg-max +╭───┬─────────╮ +│ # │ arg_max │ +├───┼─────────┤ +│ 0 │ 1 │ +╰───┴─────────╯ + +``` diff --git a/commands/docs/polars_arg-min.md b/commands/docs/polars_arg-min.md new file mode 100644 index 0000000000..4bc079c7c4 --- /dev/null +++ b/commands/docs/polars_arg-min.md @@ -0,0 +1,40 @@ +--- +title: polars arg-min +categories: | + dataframe +version: 0.93.0 +dataframe: | + Return index for min value in series. +usage: | + Return index for min value in series. +feature: default +--- + + +# `polars arg-min` for [dataframe](/commands/categories/dataframe.md) + +
Return index for min value in series.
+ +## Signature + +```> polars arg-min {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns index for min value +```nu +> [1 3 2] | polars into-df | polars arg-min +╭───┬─────────╮ +│ # │ arg_min │ +├───┼─────────┤ +│ 0 │ 0 │ +╰───┴─────────╯ + +``` diff --git a/commands/docs/polars_arg-sort.md b/commands/docs/polars_arg-sort.md new file mode 100644 index 0000000000..6accca30b2 --- /dev/null +++ b/commands/docs/polars_arg-sort.md @@ -0,0 +1,65 @@ +--- +title: polars arg-sort +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns indexes for a sorted series. +usage: | + Returns indexes for a sorted series. +feature: default +--- + + +# `polars arg-sort` for [dataframe](/commands/categories/dataframe.md) + +
Returns indexes for a sorted series.
+ +## Signature + +```> polars arg-sort {flags} ``` + +## Flags + + - `--reverse, -r`: reverse order + - `--nulls-last, -n`: nulls ordered last + - `--maintain-order, -m`: maintain order on sorted items + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns indexes for a sorted series +```nu +> [1 2 2 3 3] | polars into-df | polars arg-sort +╭───┬──────────╮ +│ # │ arg_sort │ +├───┼──────────┤ +│ 0 │ 0 │ +│ 1 │ 1 │ +│ 2 │ 2 │ +│ 3 │ 3 │ +│ 4 │ 4 │ +╰───┴──────────╯ + +``` + +Returns indexes for a sorted series +```nu +> [1 2 2 3 3] | polars into-df | polars arg-sort --reverse +╭───┬──────────╮ +│ # │ arg_sort │ +├───┼──────────┤ +│ 0 │ 3 │ +│ 1 │ 4 │ +│ 2 │ 1 │ +│ 3 │ 2 │ +│ 4 │ 0 │ +╰───┴──────────╯ + +``` diff --git a/commands/docs/polars_arg-true.md b/commands/docs/polars_arg-true.md new file mode 100644 index 0000000000..04543c82ad --- /dev/null +++ b/commands/docs/polars_arg-true.md @@ -0,0 +1,40 @@ +--- +title: polars arg-true +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns indexes where values are true. +usage: | + Returns indexes where values are true. +feature: default +--- + + +# `polars arg-true` for [dataframe](/commands/categories/dataframe.md) + +
Returns indexes where values are true.
+ +## Signature + +```> polars arg-true {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns indexes where values are true +```nu +> [false true false] | polars into-df | polars arg-true +╭───┬──────────╮ +│ # │ arg_true │ +├───┼──────────┤ +│ 0 │ 1 │ +╰───┴──────────╯ + +``` diff --git a/commands/docs/polars_arg-unique.md b/commands/docs/polars_arg-unique.md new file mode 100644 index 0000000000..43069763cd --- /dev/null +++ b/commands/docs/polars_arg-unique.md @@ -0,0 +1,42 @@ +--- +title: polars arg-unique +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns indexes for unique values. +usage: | + Returns indexes for unique values. +feature: default +--- + + +# `polars arg-unique` for [dataframe](/commands/categories/dataframe.md) + +
Returns indexes for unique values.
+ +## Signature + +```> polars arg-unique {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns indexes for unique values +```nu +> [1 2 2 3 3] | polars into-df | polars arg-unique +╭───┬────────────╮ +│ # │ arg_unique │ +├───┼────────────┤ +│ 0 │ 0 │ +│ 1 │ 1 │ +│ 2 │ 3 │ +╰───┴────────────╯ + +``` diff --git a/commands/docs/polars_arg-where.md b/commands/docs/polars_arg-where.md new file mode 100644 index 0000000000..eefa631189 --- /dev/null +++ b/commands/docs/polars_arg-where.md @@ -0,0 +1,46 @@ +--- +title: polars arg-where +categories: | + expression +version: 0.93.0 +expression: | + Creates an expression that returns the arguments where expression is true. +usage: | + Creates an expression that returns the arguments where expression is true. +feature: default +--- + + +# `polars arg-where` for [expression](/commands/categories/expression.md) + +
Creates an expression that returns the arguments where expression is true.
+ +## Signature + +```> polars arg-where {flags} (column name)``` + +## Parameters + + - `column name`: Expression to evaluate + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Return a dataframe where the value match the expression +```nu +> let df = ([[a b]; [one 1] [two 2] [three 3]] | polars into-df); + $df | polars select (polars arg-where ((polars col b) >= 2) | polars as b_arg) +╭───┬───────╮ +│ # │ b_arg │ +├───┼───────┤ +│ 0 │ 1 │ +│ 1 │ 2 │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_as-date.md b/commands/docs/polars_as-date.md new file mode 100644 index 0000000000..cc7e905c1d --- /dev/null +++ b/commands/docs/polars_as-date.md @@ -0,0 +1,49 @@ +--- +title: polars as-date +categories: | + dataframe +version: 0.93.0 +dataframe: | + Converts string to date. +usage: | + Converts string to date. +feature: default +--- + + +# `polars as-date` for [dataframe](/commands/categories/dataframe.md) + +
Converts string to date.
+ +## Signature + +```> polars as-date {flags} (format)``` + +## Flags + + - `--not-exact, -n`: the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01) + +## Parameters + + - `format`: formatting date string + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Converts string to date +```nu +> ["2021-12-30" "2021-12-31"] | polars into-df | polars as-date "%Y-%m-%d" + +``` + +## Notes +Format example: + "%Y-%m-%d" => 2021-12-31 + "%d-%m-%Y" => 31-12-2021 + "%Y%m%d" => 2021319 (2021-03-19) \ No newline at end of file diff --git a/commands/docs/polars_as-datetime.md b/commands/docs/polars_as-datetime.md new file mode 100644 index 0000000000..e5a6ca6b19 --- /dev/null +++ b/commands/docs/polars_as-datetime.md @@ -0,0 +1,75 @@ +--- +title: polars as-datetime +categories: | + dataframe +version: 0.93.0 +dataframe: | + Converts string to datetime. +usage: | + Converts string to datetime. +feature: default +--- + + +# `polars as-datetime` for [dataframe](/commands/categories/dataframe.md) + +
Converts string to datetime.
+ +## Signature + +```> polars as-datetime {flags} (format)``` + +## Flags + + - `--not-exact, -n`: the format string may be contained in the date (e.g. foo-2021-01-01-bar could match 2021-01-01) + +## Parameters + + - `format`: formatting date time string + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Converts string to datetime +```nu +> ["2021-12-30 00:00:00" "2021-12-31 00:00:00"] | polars into-df | polars as-datetime "%Y-%m-%d %H:%M:%S" +╭───┬─────────────╮ +│ # │ datetime │ +├───┼─────────────┤ +│ 0 │ 2 years ago │ +│ 1 │ 2 years ago │ +╰───┴─────────────╯ + +``` + +Converts string to datetime with high resolutions +```nu +> ["2021-12-30 00:00:00.123456789" "2021-12-31 00:00:00.123456789"] | polars into-df | polars as-datetime "%Y-%m-%d %H:%M:%S.%9f" +╭───┬─────────────╮ +│ # │ datetime │ +├───┼─────────────┤ +│ 0 │ 2 years ago │ +│ 1 │ 2 years ago │ +╰───┴─────────────╯ + +``` + +## Notes +Format example: + "%y/%m/%d %H:%M:%S" => 21/12/31 12:54:98 + "%y-%m-%d %H:%M:%S" => 2021-12-31 24:58:01 + "%y/%m/%d %H:%M:%S" => 21/12/31 24:58:01 + "%y%m%d %H:%M:%S" => 210319 23:58:50 + "%Y/%m/%d %H:%M:%S" => 2021/12/31 12:54:98 + "%Y-%m-%d %H:%M:%S" => 2021-12-31 24:58:01 + "%Y/%m/%d %H:%M:%S" => 2021/12/31 24:58:01 + "%Y%m%d %H:%M:%S" => 20210319 23:58:50 + "%FT%H:%M:%S" => 2019-04-18T02:45:55 + "%FT%H:%M:%S.%6f" => microseconds + "%FT%H:%M:%S.%9f" => nanoseconds \ No newline at end of file diff --git a/commands/docs/polars_as.md b/commands/docs/polars_as.md new file mode 100644 index 0000000000..34220134f7 --- /dev/null +++ b/commands/docs/polars_as.md @@ -0,0 +1,45 @@ +--- +title: polars as +categories: | + expression +version: 0.93.0 +expression: | + Creates an alias expression. +usage: | + Creates an alias expression. +feature: default +--- + + +# `polars as` for [expression](/commands/categories/expression.md) + +
Creates an alias expression.
+ +## Signature + +```> polars as {flags} (Alias name)``` + +## Parameters + + - `Alias name`: Alias name for the expression + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates and alias expression +```nu +> polars col a | polars as new_a | polars into-nu +╭───────┬────────────────────╮ +│ │ ╭───────┬────────╮ │ +│ expr │ │ expr │ column │ │ +│ │ │ value │ a │ │ +│ │ ╰───────┴────────╯ │ +│ alias │ new_a │ +╰───────┴────────────────────╯ +``` diff --git a/commands/docs/polars_cache.md b/commands/docs/polars_cache.md new file mode 100644 index 0000000000..f237ebf218 --- /dev/null +++ b/commands/docs/polars_cache.md @@ -0,0 +1,35 @@ +--- +title: polars cache +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Caches operations in a new LazyFrame. +usage: | + Caches operations in a new LazyFrame. +feature: default +--- + + +# `polars cache` for [lazyframe](/commands/categories/lazyframe.md) + +
Caches operations in a new LazyFrame.
+ +## Signature + +```> polars cache {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Caches the result into a new LazyFrame +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars reverse | polars cache + +``` diff --git a/commands/docs/polars_cast.md b/commands/docs/polars_cast.md new file mode 100644 index 0000000000..881a361c7d --- /dev/null +++ b/commands/docs/polars_cast.md @@ -0,0 +1,58 @@ +--- +title: polars cast +categories: | + dataframe +version: 0.93.0 +dataframe: | + Cast a column to a different dtype. +usage: | + Cast a column to a different dtype. +feature: default +--- + + +# `polars cast` for [dataframe](/commands/categories/dataframe.md) + +
Cast a column to a different dtype.
+ +## Signature + +```> polars cast {flags} (dtype) (column)``` + +## Parameters + + - `dtype`: The dtype to cast the column to + - `column`: The column to cast. Required when used with a dataframe. + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Cast a column in a dataframe to a different dtype +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars cast u8 a | polars schema +╭───┬─────╮ +│ a │ u8 │ +│ b │ i64 │ +╰───┴─────╯ +``` + +Cast a column in a lazy dataframe to a different dtype +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars into-lazy | polars cast u8 a | polars schema +╭───┬─────╮ +│ a │ u8 │ +│ b │ i64 │ +╰───┴─────╯ +``` + +Cast a column in a expression to a different dtype +```nu +> [[a b]; [1 2] [1 4]] | polars into-df | polars group-by a | polars agg [ (polars col b | polars cast u8 | polars min | polars as "b_min") ] | polars schema + +``` diff --git a/commands/docs/polars_col.md b/commands/docs/polars_col.md new file mode 100644 index 0000000000..af53c8f93f --- /dev/null +++ b/commands/docs/polars_col.md @@ -0,0 +1,42 @@ +--- +title: polars col +categories: | + expression +version: 0.93.0 +expression: | + Creates a named column expression. +usage: | + Creates a named column expression. +feature: default +--- + + +# `polars col` for [expression](/commands/categories/expression.md) + +
Creates a named column expression.
+ +## Signature + +```> polars col {flags} (column name)``` + +## Parameters + + - `column name`: Name of column to be used + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates a named column expression and converts it to a nu object +```nu +> polars col a | polars into-nu +╭───────┬────────╮ +│ expr │ column │ +│ value │ a │ +╰───────┴────────╯ +``` diff --git a/commands/docs/polars_collect.md b/commands/docs/polars_collect.md new file mode 100644 index 0000000000..001d4d5dbe --- /dev/null +++ b/commands/docs/polars_collect.md @@ -0,0 +1,41 @@ +--- +title: polars collect +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Collect lazy dataframe into eager dataframe. +usage: | + Collect lazy dataframe into eager dataframe. +feature: default +--- + + +# `polars collect` for [lazyframe](/commands/categories/lazyframe.md) + +
Collect lazy dataframe into eager dataframe.
+ +## Signature + +```> polars collect {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +drop duplicates +```nu +> [[a b]; [1 2] [3 4]] | polars into-lazy | polars collect +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_columns.md b/commands/docs/polars_columns.md new file mode 100644 index 0000000000..771937b5bb --- /dev/null +++ b/commands/docs/polars_columns.md @@ -0,0 +1,39 @@ +--- +title: polars columns +categories: | + dataframe +version: 0.93.0 +dataframe: | + Show dataframe columns. +usage: | + Show dataframe columns. +feature: default +--- + + +# `polars columns` for [dataframe](/commands/categories/dataframe.md) + +
Show dataframe columns.
+ +## Signature + +```> polars columns {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Dataframe columns +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars columns +╭───┬───╮ +│ 0 │ a │ +│ 1 │ b │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_concat-str.md b/commands/docs/polars_concat-str.md new file mode 100644 index 0000000000..68f6532b23 --- /dev/null +++ b/commands/docs/polars_concat-str.md @@ -0,0 +1,47 @@ +--- +title: polars concat-str +categories: | + expression +version: 0.93.0 +expression: | + Creates a concat string expression. +usage: | + Creates a concat string expression. +feature: default +--- + + +# `polars concat-str` for [expression](/commands/categories/expression.md) + +
Creates a concat string expression.
+ +## Signature + +```> polars concat-str {flags} (separator) (concat expressions)``` + +## Parameters + + - `separator`: Separator used during the concatenation + - `concat expressions`: Expression(s) that define the string concatenation + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates a concat string expression +```nu +> let df = ([[a b c]; [one two 1] [three four 2]] | polars into-df); + $df | polars with-column ((polars concat-str "-" [(polars col a) (polars col b) ((polars col c) * 2)]) | polars as concat) +╭───┬───────┬──────┬───┬──────────────╮ +│ # │ a │ b │ c │ concat │ +├───┼───────┼──────┼───┼──────────────┤ +│ 0 │ one │ two │ 1 │ one-two-2 │ +│ 1 │ three │ four │ 2 │ three-four-4 │ +╰───┴───────┴──────┴───┴──────────────╯ + +``` diff --git a/commands/docs/polars_concatenate.md b/commands/docs/polars_concatenate.md new file mode 100644 index 0000000000..ef19f2101b --- /dev/null +++ b/commands/docs/polars_concatenate.md @@ -0,0 +1,47 @@ +--- +title: polars concatenate +categories: | + dataframe +version: 0.93.0 +dataframe: | + Concatenates strings with other array. +usage: | + Concatenates strings with other array. +feature: default +--- + + +# `polars concatenate` for [dataframe](/commands/categories/dataframe.md) + +
Concatenates strings with other array.
+ +## Signature + +```> polars concatenate {flags} (other)``` + +## Parameters + + - `other`: Other array with string to be concatenated + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Concatenate string +```nu +> let other = ([za xs cd] | polars into-df); + [abc abc abc] | polars into-df | polars concatenate $other +╭───┬───────╮ +│ # │ 0 │ +├───┼───────┤ +│ 0 │ abcza │ +│ 1 │ abcxs │ +│ 2 │ abccd │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_contains.md b/commands/docs/polars_contains.md new file mode 100644 index 0000000000..8ae0e2a263 --- /dev/null +++ b/commands/docs/polars_contains.md @@ -0,0 +1,46 @@ +--- +title: polars contains +categories: | + dataframe +version: 0.93.0 +dataframe: | + Checks if a pattern is contained in a string. +usage: | + Checks if a pattern is contained in a string. +feature: default +--- + + +# `polars contains` for [dataframe](/commands/categories/dataframe.md) + +
Checks if a pattern is contained in a string.
+ +## Signature + +```> polars contains {flags} (pattern)``` + +## Parameters + + - `pattern`: Regex pattern to be searched + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns boolean indicating if pattern was found +```nu +> [abc acb acb] | polars into-df | polars contains ab +╭───┬───────╮ +│ # │ 0 │ +├───┼───────┤ +│ 0 │ true │ +│ 1 │ false │ +│ 2 │ false │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_count-null.md b/commands/docs/polars_count-null.md new file mode 100644 index 0000000000..27793f868e --- /dev/null +++ b/commands/docs/polars_count-null.md @@ -0,0 +1,41 @@ +--- +title: polars count-null +categories: | + dataframe +version: 0.93.0 +dataframe: | + Counts null values. +usage: | + Counts null values. +feature: default +--- + + +# `polars count-null` for [dataframe](/commands/categories/dataframe.md) + +
Counts null values.
+ +## Signature + +```> polars count-null {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Counts null values +```nu +> let s = ([1 1 0 0 3 3 4] | polars into-df); + ($s / $s) | polars count-null +╭───┬────────────╮ +│ # │ count_null │ +├───┼────────────┤ +│ 0 │ 2 │ +╰───┴────────────╯ + +``` diff --git a/commands/docs/polars_count.md b/commands/docs/polars_count.md new file mode 100644 index 0000000000..8e070eb8af --- /dev/null +++ b/commands/docs/polars_count.md @@ -0,0 +1,35 @@ +--- +title: polars count +categories: | + expression +version: 0.93.0 +expression: | + Creates a count expression. +usage: | + Creates a count expression. +feature: default +--- + + +# `polars count` for [expression](/commands/categories/expression.md) + +
Creates a count expression.
+ +## Signature + +```> polars count {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + + +```nu +> + +``` diff --git a/commands/docs/polars_cumulative.md b/commands/docs/polars_cumulative.md new file mode 100644 index 0000000000..9f40af592f --- /dev/null +++ b/commands/docs/polars_cumulative.md @@ -0,0 +1,52 @@ +--- +title: polars cumulative +categories: | + dataframe +version: 0.93.0 +dataframe: | + Cumulative calculation for a series. +usage: | + Cumulative calculation for a series. +feature: default +--- + + +# `polars cumulative` for [dataframe](/commands/categories/dataframe.md) + +
Cumulative calculation for a series.
+ +## Signature + +```> polars cumulative {flags} (type)``` + +## Flags + + - `--reverse, -r`: Reverse cumulative calculation + +## Parameters + + - `type`: rolling operation + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Cumulative sum for a series +```nu +> [1 2 3 4 5] | polars into-df | polars cumulative sum +╭───┬──────────────────╮ +│ # │ 0_cumulative_sum │ +├───┼──────────────────┤ +│ 0 │ 1 │ +│ 1 │ 3 │ +│ 2 │ 6 │ +│ 3 │ 10 │ +│ 4 │ 15 │ +╰───┴──────────────────╯ + +``` diff --git a/commands/docs/polars_datepart.md b/commands/docs/polars_datepart.md new file mode 100644 index 0000000000..de61b471df --- /dev/null +++ b/commands/docs/polars_datepart.md @@ -0,0 +1,62 @@ +--- +title: polars datepart +categories: | + expression +version: 0.93.0 +expression: | + Creates an expression for capturing the specified datepart in a column. +usage: | + Creates an expression for capturing the specified datepart in a column. +feature: default +--- + + +# `polars datepart` for [expression](/commands/categories/expression.md) + +
Creates an expression for capturing the specified datepart in a column.
+ +## Signature + +```> polars datepart {flags} (Datepart name)``` + +## Parameters + + - `Datepart name`: Part of the date to capture. Possible values are year, quarter, month, week, weekday, day, hour, minute, second, millisecond, microsecond, nanosecond + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates an expression to capture the year date part +```nu +> [["2021-12-30T01:02:03.123456789"]] | polars into-df | polars as-datetime "%Y-%m-%dT%H:%M:%S.%9f" | polars with-column [(polars col datetime | polars datepart year | polars as datetime_year )] +╭───┬─────────────┬───────────────╮ +│ # │ datetime │ datetime_year │ +├───┼─────────────┼───────────────┤ +│ 0 │ 2 years ago │ 2021 │ +╰───┴─────────────┴───────────────╯ + +``` + +Creates an expression to capture multiple date parts +```nu +> [["2021-12-30T01:02:03.123456789"]] | polars into-df | polars as-datetime "%Y-%m-%dT%H:%M:%S.%9f" | + polars with-column [ (polars col datetime | polars datepart year | polars as datetime_year ), + (polars col datetime | polars datepart month | polars as datetime_month ), + (polars col datetime | polars datepart day | polars as datetime_day ), + (polars col datetime | polars datepart hour | polars as datetime_hour ), + (polars col datetime | polars datepart minute | polars as datetime_minute ), + (polars col datetime | polars datepart second | polars as datetime_second ), + (polars col datetime | polars datepart nanosecond | polars as datetime_ns ) ] +╭───┬─────────────┬───────────────┬────────────────┬──────────────┬───────────────┬─────────────────┬─────────────────┬─────────────╮ +│ # │ datetime │ datetime_year │ datetime_month │ datetime_day │ datetime_hour │ datetime_minute │ datetime_second │ datetime_ns │ +├───┼─────────────┼───────────────┼────────────────┼──────────────┼───────────────┼─────────────────┼─────────────────┼─────────────┤ +│ 0 │ 2 years ago │ 2021 │ 12 │ 30 │ 1 │ 2 │ 3 │ 123456789 │ +╰───┴─────────────┴───────────────┴────────────────┴──────────────┴───────────────┴─────────────────┴─────────────────┴─────────────╯ + +``` diff --git a/commands/docs/polars_drop-duplicates.md b/commands/docs/polars_drop-duplicates.md new file mode 100644 index 0000000000..aa0a291afc --- /dev/null +++ b/commands/docs/polars_drop-duplicates.md @@ -0,0 +1,50 @@ +--- +title: polars drop-duplicates +categories: | + dataframe +version: 0.93.0 +dataframe: | + Drops duplicate values in dataframe. +usage: | + Drops duplicate values in dataframe. +feature: default +--- + + +# `polars drop-duplicates` for [dataframe](/commands/categories/dataframe.md) + +
Drops duplicate values in dataframe.
+ +## Signature + +```> polars drop-duplicates {flags} (subset)``` + +## Flags + + - `--maintain, -m`: maintain order + - `--last, -l`: keeps last duplicate value (by default keeps first) + +## Parameters + + - `subset`: subset of columns to drop duplicates + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +drop duplicates +```nu +> [[a b]; [1 2] [3 4] [1 2]] | polars into-df | polars drop-duplicates +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 3 │ 4 │ +│ 1 │ 1 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_drop-nulls.md b/commands/docs/polars_drop-nulls.md new file mode 100644 index 0000000000..c0b0c89703 --- /dev/null +++ b/commands/docs/polars_drop-nulls.md @@ -0,0 +1,63 @@ +--- +title: polars drop-nulls +categories: | + dataframe +version: 0.93.0 +dataframe: | + Drops null values in dataframe. +usage: | + Drops null values in dataframe. +feature: default +--- + + +# `polars drop-nulls` for [dataframe](/commands/categories/dataframe.md) + +
Drops null values in dataframe.
+ +## Signature + +```> polars drop-nulls {flags} (subset)``` + +## Parameters + + - `subset`: subset of columns to drop nulls + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +drop null values in dataframe +```nu +> let df = ([[a b]; [1 2] [3 0] [1 2]] | polars into-df); + let res = ($df.b / $df.b); + let a = ($df | polars with-column $res --name res); + $a | polars drop-nulls +╭───┬───┬───┬─────╮ +│ # │ a │ b │ res │ +├───┼───┼───┼─────┤ +│ 0 │ 1 │ 2 │ 1 │ +│ 1 │ 1 │ 2 │ 1 │ +╰───┴───┴───┴─────╯ + +``` + +drop null values in dataframe +```nu +> let s = ([1 2 0 0 3 4] | polars into-df); + ($s / $s) | polars drop-nulls +╭───┬─────────╮ +│ # │ div_0_0 │ +├───┼─────────┤ +│ 0 │ 1 │ +│ 1 │ 1 │ +│ 2 │ 1 │ +│ 3 │ 1 │ +╰───┴─────────╯ + +``` diff --git a/commands/docs/polars_drop.md b/commands/docs/polars_drop.md new file mode 100644 index 0000000000..7bc90b86cc --- /dev/null +++ b/commands/docs/polars_drop.md @@ -0,0 +1,45 @@ +--- +title: polars drop +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates a new dataframe by dropping the selected columns. +usage: | + Creates a new dataframe by dropping the selected columns. +feature: default +--- + + +# `polars drop` for [dataframe](/commands/categories/dataframe.md) + +
Creates a new dataframe by dropping the selected columns.
+ +## Signature + +```> polars drop {flags} ...rest``` + +## Parameters + + - `...rest`: column names to be dropped + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +drop column a +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars drop a +╭───┬───╮ +│ # │ b │ +├───┼───┤ +│ 0 │ 2 │ +│ 1 │ 4 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_dummies.md b/commands/docs/polars_dummies.md new file mode 100644 index 0000000000..c86aa0730b --- /dev/null +++ b/commands/docs/polars_dummies.md @@ -0,0 +1,60 @@ +--- +title: polars dummies +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates a new dataframe with dummy variables. +usage: | + Creates a new dataframe with dummy variables. +feature: default +--- + + +# `polars dummies` for [dataframe](/commands/categories/dataframe.md) + +
Creates a new dataframe with dummy variables.
+ +## Signature + +```> polars dummies {flags} ``` + +## Flags + + - `--drop-first, -d`: Drop first row + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create new dataframe with dummy variables from a dataframe +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars dummies +╭───┬─────┬─────┬─────┬─────╮ +│ # │ a_1 │ a_3 │ b_2 │ b_4 │ +├───┼─────┼─────┼─────┼─────┤ +│ 0 │ 1 │ 0 │ 1 │ 0 │ +│ 1 │ 0 │ 1 │ 0 │ 1 │ +╰───┴─────┴─────┴─────┴─────╯ + +``` + +Create new dataframe with dummy variables from a series +```nu +> [1 2 2 3 3] | polars into-df | polars dummies +╭───┬─────┬─────┬─────╮ +│ # │ 0_1 │ 0_2 │ 0_3 │ +├───┼─────┼─────┼─────┤ +│ 0 │ 1 │ 0 │ 0 │ +│ 1 │ 0 │ 1 │ 0 │ +│ 2 │ 0 │ 1 │ 0 │ +│ 3 │ 0 │ 0 │ 1 │ +│ 4 │ 0 │ 0 │ 1 │ +╰───┴─────┴─────┴─────╯ + +``` diff --git a/commands/docs/polars_explode.md b/commands/docs/polars_explode.md new file mode 100644 index 0000000000..7f5e463913 --- /dev/null +++ b/commands/docs/polars_explode.md @@ -0,0 +1,61 @@ +--- +title: polars explode +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Explodes a dataframe or creates a explode expression. +usage: | + Explodes a dataframe or creates a explode expression. +feature: default +--- + + +# `polars explode` for [lazyframe](/commands/categories/lazyframe.md) + +
Explodes a dataframe or creates a explode expression.
+ +## Signature + +```> polars explode {flags} ...rest``` + +## Parameters + + - `...rest`: columns to explode, only applicable for dataframes + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Explode the specified dataframe +```nu +> [[id name hobbies]; [1 Mercy [Cycling Knitting]] [2 Bob [Skiing Football]]] | polars into-df | polars explode hobbies | polars collect +╭───┬────┬───────┬──────────╮ +│ # │ id │ name │ hobbies │ +├───┼────┼───────┼──────────┤ +│ 0 │ 1 │ Mercy │ Cycling │ +│ 1 │ 1 │ Mercy │ Knitting │ +│ 2 │ 2 │ Bob │ Skiing │ +│ 3 │ 2 │ Bob │ Football │ +╰───┴────┴───────┴──────────╯ + +``` + +Select a column and explode the values +```nu +> [[id name hobbies]; [1 Mercy [Cycling Knitting]] [2 Bob [Skiing Football]]] | polars into-df | polars select (polars col hobbies | polars explode) +╭───┬──────────╮ +│ # │ hobbies │ +├───┼──────────┤ +│ 0 │ Cycling │ +│ 1 │ Knitting │ +│ 2 │ Skiing │ +│ 3 │ Football │ +╰───┴──────────╯ + +``` diff --git a/commands/docs/polars_expr-not.md b/commands/docs/polars_expr-not.md new file mode 100644 index 0000000000..dbc723c34c --- /dev/null +++ b/commands/docs/polars_expr-not.md @@ -0,0 +1,35 @@ +--- +title: polars expr-not +categories: | + expression +version: 0.93.0 +expression: | + Creates a not expression. +usage: | + Creates a not expression. +feature: default +--- + + +# `polars expr-not` for [expression](/commands/categories/expression.md) + +
Creates a not expression.
+ +## Signature + +```> polars expr-not {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates a not expression +```nu +> (polars col a) > 2) | polars expr-not + +``` diff --git a/commands/docs/polars_fetch.md b/commands/docs/polars_fetch.md new file mode 100644 index 0000000000..ba2610c5a4 --- /dev/null +++ b/commands/docs/polars_fetch.md @@ -0,0 +1,45 @@ +--- +title: polars fetch +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Collects the lazyframe to the selected rows. +usage: | + Collects the lazyframe to the selected rows. +feature: default +--- + + +# `polars fetch` for [lazyframe](/commands/categories/lazyframe.md) + +
Collects the lazyframe to the selected rows.
+ +## Signature + +```> polars fetch {flags} (rows)``` + +## Parameters + + - `rows`: number of rows to be fetched from lazyframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Fetch a rows from the dataframe +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars fetch 2 +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 6 │ 2 │ +│ 1 │ 4 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_fill-nan.md b/commands/docs/polars_fill-nan.md new file mode 100644 index 0000000000..d1f63d0c9e --- /dev/null +++ b/commands/docs/polars_fill-nan.md @@ -0,0 +1,60 @@ +--- +title: polars fill-nan +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Replaces NaN values with the given expression. +usage: | + Replaces NaN values with the given expression. +feature: default +--- + + +# `polars fill-nan` for [lazyframe](/commands/categories/lazyframe.md) + +
Replaces NaN values with the given expression.
+ +## Signature + +```> polars fill-nan {flags} (fill)``` + +## Parameters + + - `fill`: Expression to use to fill the NAN values + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Fills the NaN values with 0 +```nu +> [1 2 NaN 3 NaN] | polars into-df | polars fill-nan 0 +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 1 │ +│ 1 │ 2 │ +│ 2 │ 0 │ +│ 3 │ 3 │ +│ 4 │ 0 │ +╰───┴───╯ + +``` + +Fills the NaN values of a whole dataframe +```nu +> [[a b]; [0.2 1] [0.1 NaN]] | polars into-df | polars fill-nan 0 +╭───┬──────┬───╮ +│ # │ a │ b │ +├───┼──────┼───┤ +│ 0 │ 0.20 │ 1 │ +│ 1 │ 0.10 │ 0 │ +╰───┴──────┴───╯ + +``` diff --git a/commands/docs/polars_fill-null.md b/commands/docs/polars_fill-null.md new file mode 100644 index 0000000000..832bce7c40 --- /dev/null +++ b/commands/docs/polars_fill-null.md @@ -0,0 +1,48 @@ +--- +title: polars fill-null +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Replaces NULL values with the given expression. +usage: | + Replaces NULL values with the given expression. +feature: default +--- + + +# `polars fill-null` for [lazyframe](/commands/categories/lazyframe.md) + +
Replaces NULL values with the given expression.
+ +## Signature + +```> polars fill-null {flags} (fill)``` + +## Parameters + + - `fill`: Expression to use to fill the null values + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Fills the null values by 0 +```nu +> [1 2 2 3 3] | polars into-df | polars shift 2 | polars fill-null 0 +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 0 │ +│ 1 │ 0 │ +│ 2 │ 1 │ +│ 3 │ 2 │ +│ 4 │ 2 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_filter-with.md b/commands/docs/polars_filter-with.md new file mode 100644 index 0000000000..ac4c5bbbd0 --- /dev/null +++ b/commands/docs/polars_filter-with.md @@ -0,0 +1,56 @@ +--- +title: polars filter-with +categories: | + dataframe or lazyframe +version: 0.93.0 +dataframe_or_lazyframe: | + Filters dataframe using a mask or expression as reference. +usage: | + Filters dataframe using a mask or expression as reference. +feature: default +--- + + +# `polars filter-with` for [dataframe or lazyframe](/commands/categories/dataframe or lazyframe.md) + +
Filters dataframe using a mask or expression as reference.
+ +## Signature + +```> polars filter-with {flags} (mask or expression)``` + +## Parameters + + - `mask or expression`: boolean mask used to filter data + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Filter dataframe using a bool mask +```nu +> let mask = ([true false] | polars into-df); + [[a b]; [1 2] [3 4]] | polars into-df | polars filter-with $mask +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +╰───┴───┴───╯ + +``` + +Filter dataframe using an expression +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars filter-with ((polars col a) > 1) +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_filter.md b/commands/docs/polars_filter.md new file mode 100644 index 0000000000..8ba7f58af5 --- /dev/null +++ b/commands/docs/polars_filter.md @@ -0,0 +1,45 @@ +--- +title: polars filter +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Filter dataframe based in expression. +usage: | + Filter dataframe based in expression. +feature: default +--- + + +# `polars filter` for [lazyframe](/commands/categories/lazyframe.md) + +
Filter dataframe based in expression.
+ +## Signature + +```> polars filter {flags} (filter expression)``` + +## Parameters + + - `filter expression`: Expression that define the column selection + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Filter dataframe using an expression +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars filter ((polars col a) >= 4) +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 6 │ 2 │ +│ 1 │ 4 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_first.md b/commands/docs/polars_first.md new file mode 100644 index 0000000000..b929411f39 --- /dev/null +++ b/commands/docs/polars_first.md @@ -0,0 +1,62 @@ +--- +title: polars first +categories: | + dataframe +version: 0.93.0 +dataframe: | + Show only the first number of rows or create a first expression +usage: | + Show only the first number of rows or create a first expression +feature: default +--- + + +# `polars first` for [dataframe](/commands/categories/dataframe.md) + +
Show only the first number of rows or create a first expression
+ +## Signature + +```> polars first {flags} (rows)``` + +## Parameters + + - `rows`: starting from the front, the number of rows to return + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Return the first row of a dataframe +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars first +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +╰───┴───┴───╯ + +``` + +Return the first two rows of a dataframe +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars first 2 +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` + +Creates a first expression from a column +```nu +> polars col a | polars first + +``` diff --git a/commands/docs/polars_flatten.md b/commands/docs/polars_flatten.md new file mode 100644 index 0000000000..b0b4e1c025 --- /dev/null +++ b/commands/docs/polars_flatten.md @@ -0,0 +1,61 @@ +--- +title: polars flatten +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + An alias for polars explode. +usage: | + An alias for polars explode. +feature: default +--- + + +# `polars flatten` for [lazyframe](/commands/categories/lazyframe.md) + +
An alias for polars explode.
+ +## Signature + +```> polars flatten {flags} ...rest``` + +## Parameters + + - `...rest`: columns to flatten, only applicable for dataframes + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Flatten the specified dataframe +```nu +> [[id name hobbies]; [1 Mercy [Cycling Knitting]] [2 Bob [Skiing Football]]] | polars into-df | polars flatten hobbies | polars collect +╭───┬────┬───────┬──────────╮ +│ # │ id │ name │ hobbies │ +├───┼────┼───────┼──────────┤ +│ 0 │ 1 │ Mercy │ Cycling │ +│ 1 │ 1 │ Mercy │ Knitting │ +│ 2 │ 2 │ Bob │ Skiing │ +│ 3 │ 2 │ Bob │ Football │ +╰───┴────┴───────┴──────────╯ + +``` + +Select a column and flatten the values +```nu +> [[id name hobbies]; [1 Mercy [Cycling Knitting]] [2 Bob [Skiing Football]]] | polars into-df | polars select (polars col hobbies | polars flatten) +╭───┬──────────╮ +│ # │ hobbies │ +├───┼──────────┤ +│ 0 │ Cycling │ +│ 1 │ Knitting │ +│ 2 │ Skiing │ +│ 3 │ Football │ +╰───┴──────────╯ + +``` diff --git a/commands/docs/polars_get-day.md b/commands/docs/polars_get-day.md new file mode 100644 index 0000000000..4d689b72d0 --- /dev/null +++ b/commands/docs/polars_get-day.md @@ -0,0 +1,43 @@ +--- +title: polars get-day +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets day from date. +usage: | + Gets day from date. +feature: default +--- + + +# `polars get-day` for [dataframe](/commands/categories/dataframe.md) + +
Gets day from date.
+ +## Signature + +```> polars get-day {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns day from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-day +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 4 │ +│ 1 │ 4 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_get-hour.md b/commands/docs/polars_get-hour.md new file mode 100644 index 0000000000..4248b64498 --- /dev/null +++ b/commands/docs/polars_get-hour.md @@ -0,0 +1,43 @@ +--- +title: polars get-hour +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets hour from date. +usage: | + Gets hour from date. +feature: default +--- + + +# `polars get-hour` for [dataframe](/commands/categories/dataframe.md) + +
Gets hour from date.
+ +## Signature + +```> polars get-hour {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns hour from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-hour +╭───┬────╮ +│ # │ 0 │ +├───┼────┤ +│ 0 │ 16 │ +│ 1 │ 16 │ +╰───┴────╯ + +``` diff --git a/commands/docs/polars_get-minute.md b/commands/docs/polars_get-minute.md new file mode 100644 index 0000000000..670acd6ea7 --- /dev/null +++ b/commands/docs/polars_get-minute.md @@ -0,0 +1,43 @@ +--- +title: polars get-minute +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets minute from date. +usage: | + Gets minute from date. +feature: default +--- + + +# `polars get-minute` for [dataframe](/commands/categories/dataframe.md) + +
Gets minute from date.
+ +## Signature + +```> polars get-minute {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns minute from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-minute +╭───┬────╮ +│ # │ 0 │ +├───┼────┤ +│ 0 │ 39 │ +│ 1 │ 39 │ +╰───┴────╯ + +``` diff --git a/commands/docs/polars_get-month.md b/commands/docs/polars_get-month.md new file mode 100644 index 0000000000..d3631f0809 --- /dev/null +++ b/commands/docs/polars_get-month.md @@ -0,0 +1,43 @@ +--- +title: polars get-month +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets month from date. +usage: | + Gets month from date. +feature: default +--- + + +# `polars get-month` for [dataframe](/commands/categories/dataframe.md) + +
Gets month from date.
+ +## Signature + +```> polars get-month {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns month from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-month +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 8 │ +│ 1 │ 8 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_get-nanosecond.md b/commands/docs/polars_get-nanosecond.md new file mode 100644 index 0000000000..214b9ec2e1 --- /dev/null +++ b/commands/docs/polars_get-nanosecond.md @@ -0,0 +1,43 @@ +--- +title: polars get-nanosecond +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets nanosecond from date. +usage: | + Gets nanosecond from date. +feature: default +--- + + +# `polars get-nanosecond` for [dataframe](/commands/categories/dataframe.md) + +
Gets nanosecond from date.
+ +## Signature + +```> polars get-nanosecond {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns nanosecond from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-nanosecond +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 0 │ +│ 1 │ 0 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_get-ordinal.md b/commands/docs/polars_get-ordinal.md new file mode 100644 index 0000000000..fa19455808 --- /dev/null +++ b/commands/docs/polars_get-ordinal.md @@ -0,0 +1,43 @@ +--- +title: polars get-ordinal +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets ordinal from date. +usage: | + Gets ordinal from date. +feature: default +--- + + +# `polars get-ordinal` for [dataframe](/commands/categories/dataframe.md) + +
Gets ordinal from date.
+ +## Signature + +```> polars get-ordinal {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns ordinal from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-ordinal +╭───┬─────╮ +│ # │ 0 │ +├───┼─────┤ +│ 0 │ 217 │ +│ 1 │ 217 │ +╰───┴─────╯ + +``` diff --git a/commands/docs/polars_get-second.md b/commands/docs/polars_get-second.md new file mode 100644 index 0000000000..02e4174e22 --- /dev/null +++ b/commands/docs/polars_get-second.md @@ -0,0 +1,43 @@ +--- +title: polars get-second +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets second from date. +usage: | + Gets second from date. +feature: default +--- + + +# `polars get-second` for [dataframe](/commands/categories/dataframe.md) + +
Gets second from date.
+ +## Signature + +```> polars get-second {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns second from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-second +╭───┬────╮ +│ # │ 0 │ +├───┼────┤ +│ 0 │ 18 │ +│ 1 │ 18 │ +╰───┴────╯ + +``` diff --git a/commands/docs/polars_get-week.md b/commands/docs/polars_get-week.md new file mode 100644 index 0000000000..4505e2422f --- /dev/null +++ b/commands/docs/polars_get-week.md @@ -0,0 +1,43 @@ +--- +title: polars get-week +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets week from date. +usage: | + Gets week from date. +feature: default +--- + + +# `polars get-week` for [dataframe](/commands/categories/dataframe.md) + +
Gets week from date.
+ +## Signature + +```> polars get-week {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns week from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-week +╭───┬────╮ +│ # │ 0 │ +├───┼────┤ +│ 0 │ 32 │ +│ 1 │ 32 │ +╰───┴────╯ + +``` diff --git a/commands/docs/polars_get-weekday.md b/commands/docs/polars_get-weekday.md new file mode 100644 index 0000000000..9c3e1d149e --- /dev/null +++ b/commands/docs/polars_get-weekday.md @@ -0,0 +1,43 @@ +--- +title: polars get-weekday +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets weekday from date. +usage: | + Gets weekday from date. +feature: default +--- + + +# `polars get-weekday` for [dataframe](/commands/categories/dataframe.md) + +
Gets weekday from date.
+ +## Signature + +```> polars get-weekday {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns weekday from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-weekday +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 2 │ +│ 1 │ 2 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_get-year.md b/commands/docs/polars_get-year.md new file mode 100644 index 0000000000..6da2c55965 --- /dev/null +++ b/commands/docs/polars_get-year.md @@ -0,0 +1,43 @@ +--- +title: polars get-year +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets year from date. +usage: | + Gets year from date. +feature: default +--- + + +# `polars get-year` for [dataframe](/commands/categories/dataframe.md) + +
Gets year from date.
+ +## Signature + +```> polars get-year {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns year from a date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars get-year +╭───┬──────╮ +│ # │ 0 │ +├───┼──────┤ +│ 0 │ 2020 │ +│ 1 │ 2020 │ +╰───┴──────╯ + +``` diff --git a/commands/docs/polars_get.md b/commands/docs/polars_get.md new file mode 100644 index 0000000000..019de77136 --- /dev/null +++ b/commands/docs/polars_get.md @@ -0,0 +1,45 @@ +--- +title: polars get +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates dataframe with the selected columns. +usage: | + Creates dataframe with the selected columns. +feature: default +--- + + +# `polars get` for [dataframe](/commands/categories/dataframe.md) + +
Creates dataframe with the selected columns.
+ +## Signature + +```> polars get {flags} ...rest``` + +## Parameters + + - `...rest`: column names to sort dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns the selected column +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars get a +╭───┬───╮ +│ # │ a │ +├───┼───┤ +│ 0 │ 1 │ +│ 1 │ 3 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_group-by.md b/commands/docs/polars_group-by.md new file mode 100644 index 0000000000..37c0ee2bfa --- /dev/null +++ b/commands/docs/polars_group-by.md @@ -0,0 +1,72 @@ +--- +title: polars group-by +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Creates a group-by object that can be used for other aggregations. +usage: | + Creates a group-by object that can be used for other aggregations. +feature: default +--- + + +# `polars group-by` for [lazyframe](/commands/categories/lazyframe.md) + +
Creates a group-by object that can be used for other aggregations.
+ +## Signature + +```> polars group-by {flags} ...rest``` + +## Parameters + + - `...rest`: Expression(s) that define the lazy group-by + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Group by and perform an aggregation +```nu +> [[a b]; [1 2] [1 4] [2 6] [2 4]] + | polars into-df + | polars group-by a + | polars agg [ + (polars col b | polars min | polars as "b_min") + (polars col b | polars max | polars as "b_max") + (polars col b | polars sum | polars as "b_sum") + ] +╭───┬───┬───────┬───────┬───────╮ +│ # │ a │ b_min │ b_max │ b_sum │ +├───┼───┼───────┼───────┼───────┤ +│ 0 │ 1 │ 2 │ 4 │ 6 │ +│ 1 │ 2 │ 4 │ 6 │ 10 │ +╰───┴───┴───────┴───────┴───────╯ + +``` + +Group by and perform an aggregation +```nu +> [[a b]; [1 2] [1 4] [2 6] [2 4]] + | polars into-lazy + | polars group-by a + | polars agg [ + (polars col b | polars min | polars as "b_min") + (polars col b | polars max | polars as "b_max") + (polars col b | polars sum | polars as "b_sum") + ] + | polars collect +╭───┬───┬───────┬───────┬───────╮ +│ # │ a │ b_min │ b_max │ b_sum │ +├───┼───┼───────┼───────┼───────┤ +│ 0 │ 1 │ 2 │ 4 │ 6 │ +│ 1 │ 2 │ 4 │ 6 │ 10 │ +╰───┴───┴───────┴───────┴───────╯ + +``` diff --git a/commands/docs/polars_implode.md b/commands/docs/polars_implode.md new file mode 100644 index 0000000000..15893f32b5 --- /dev/null +++ b/commands/docs/polars_implode.md @@ -0,0 +1,35 @@ +--- +title: polars implode +categories: | + expression +version: 0.93.0 +expression: | + Aggregates a group to a Series. +usage: | + Aggregates a group to a Series. +feature: default +--- + + +# `polars implode` for [expression](/commands/categories/expression.md) + +
Aggregates a group to a Series.
+ +## Signature + +```> polars implode {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + + +```nu +> + +``` diff --git a/commands/docs/polars_into-df.md b/commands/docs/polars_into-df.md new file mode 100644 index 0000000000..c733a2a3d0 --- /dev/null +++ b/commands/docs/polars_into-df.md @@ -0,0 +1,113 @@ +--- +title: polars into-df +categories: | + dataframe +version: 0.93.0 +dataframe: | + Converts a list, table or record into a dataframe. +usage: | + Converts a list, table or record into a dataframe. +feature: default +--- + + +# `polars into-df` for [dataframe](/commands/categories/dataframe.md) + +
Converts a list, table or record into a dataframe.
+ +## Signature + +```> polars into-df {flags} ``` + +## Flags + + - `--schema, -s {record}`: Polars Schema in format [{name: str}]. CSV, JSON, and JSONL files + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Takes a dictionary and creates a dataframe +```nu +> [[a b];[1 2] [3 4]] | polars into-df +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` + +Takes a list of tables and creates a dataframe +```nu +> [[1 2 a] [3 4 b] [5 6 c]] | polars into-df +╭───┬───┬───┬───╮ +│ # │ 0 │ 1 │ 2 │ +├───┼───┼───┼───┤ +│ 0 │ 1 │ 2 │ a │ +│ 1 │ 3 │ 4 │ b │ +│ 2 │ 5 │ 6 │ c │ +╰───┴───┴───┴───╯ + +``` + +Takes a list and creates a dataframe +```nu +> [a b c] | polars into-df +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ a │ +│ 1 │ b │ +│ 2 │ c │ +╰───┴───╯ + +``` + +Takes a list of booleans and creates a dataframe +```nu +> [true true false] | polars into-df +╭───┬───────╮ +│ # │ 0 │ +├───┼───────┤ +│ 0 │ true │ +│ 1 │ true │ +│ 2 │ false │ +╰───┴───────╯ + +``` + +Convert to a dataframe and provide a schema +```nu +> {a: 1, b: {a: [1 2 3]}, c: [a b c]}| polars into-df -s {a: u8, b: {a: list}, c: list} +╭───┬───┬───────────────────┬───────────╮ +│ # │ a │ b │ c │ +├───┼───┼───────────────────┼───────────┤ +│ 0 │ 1 │ ╭───┬───────────╮ │ ╭───┬───╮ │ +│ │ │ │ │ ╭───┬───╮ │ │ │ 0 │ a │ │ +│ │ │ │ a │ │ 0 │ 1 │ │ │ │ 1 │ b │ │ +│ │ │ │ │ │ 1 │ 2 │ │ │ │ 2 │ c │ │ +│ │ │ │ │ │ 2 │ 3 │ │ │ ╰───┴───╯ │ +│ │ │ │ │ ╰───┴───╯ │ │ │ +│ │ │ ╰───┴───────────╯ │ │ +╰───┴───┴───────────────────┴───────────╯ + +``` + +Convert to a dataframe and provide a schema that adds a new column +```nu +> [[a b]; [1 "foo"] [2 "bar"]] | polars into-df -s {a: u8, b:str, c:i64} | polars fill-null 3 +╭───┬───┬─────┬───╮ +│ # │ a │ b │ c │ +├───┼───┼─────┼───┤ +│ 0 │ 1 │ foo │ 3 │ +│ 1 │ 2 │ bar │ 3 │ +╰───┴───┴─────┴───╯ + +``` diff --git a/commands/docs/polars_into-lazy.md b/commands/docs/polars_into-lazy.md new file mode 100644 index 0000000000..54f1d0efd7 --- /dev/null +++ b/commands/docs/polars_into-lazy.md @@ -0,0 +1,39 @@ +--- +title: polars into-lazy +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Converts a dataframe into a lazy dataframe. +usage: | + Converts a dataframe into a lazy dataframe. +feature: default +--- + + +# `polars into-lazy` for [lazyframe](/commands/categories/lazyframe.md) + +
Converts a dataframe into a lazy dataframe.
+ +## Signature + +```> polars into-lazy {flags} ``` + +## Flags + + - `--schema, -s {record}`: Polars Schema in format [{name: str}]. CSV, JSON, and JSONL files + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Takes a dictionary and creates a lazy dataframe +```nu +> [[a b];[1 2] [3 4]] | polars into-lazy + +``` diff --git a/commands/docs/polars_into-nu.md b/commands/docs/polars_into-nu.md new file mode 100644 index 0000000000..91060b302b --- /dev/null +++ b/commands/docs/polars_into-nu.md @@ -0,0 +1,66 @@ +--- +title: polars into-nu +categories: | + dataframe +version: 0.93.0 +dataframe: | + Converts a dataframe or an expression into into nushell value for access and exploration. +usage: | + Converts a dataframe or an expression into into nushell value for access and exploration. +feature: default +--- + + +# `polars into-nu` for [dataframe](/commands/categories/dataframe.md) + +
Converts a dataframe or an expression into into nushell value for access and exploration.
+ +## Signature + +```> polars into-nu {flags} ``` + +## Flags + + - `--rows, -n {number}`: number of rows to be shown + - `--tail, -t`: shows tail rows + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Shows head rows from dataframe +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars into-nu +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` + +Shows tail rows from dataframe +```nu +> [[a b]; [1 2] [5 6] [3 4]] | polars into-df | polars into-nu --tail --rows 1 +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 2 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` + +Convert a col expression into a nushell value +```nu +> polars col a | polars into-nu +╭───────┬────────╮ +│ expr │ column │ +│ value │ a │ +╰───────┴────────╯ +``` diff --git a/commands/docs/polars_is-duplicated.md b/commands/docs/polars_is-duplicated.md new file mode 100644 index 0000000000..29137a14aa --- /dev/null +++ b/commands/docs/polars_is-duplicated.md @@ -0,0 +1,61 @@ +--- +title: polars is-duplicated +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates mask indicating duplicated values. +usage: | + Creates mask indicating duplicated values. +feature: default +--- + + +# `polars is-duplicated` for [dataframe](/commands/categories/dataframe.md) + +
Creates mask indicating duplicated values.
+ +## Signature + +```> polars is-duplicated {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create mask indicating duplicated values +```nu +> [5 6 6 6 8 8 8] | polars into-df | polars is-duplicated +╭───┬───────────────╮ +│ # │ is_duplicated │ +├───┼───────────────┤ +│ 0 │ false │ +│ 1 │ true │ +│ 2 │ true │ +│ 3 │ true │ +│ 4 │ true │ +│ 5 │ true │ +│ 6 │ true │ +╰───┴───────────────╯ + +``` + +Create mask indicating duplicated rows in a dataframe +```nu +> [[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | polars into-df | polars is-duplicated +╭───┬───────────────╮ +│ # │ is_duplicated │ +├───┼───────────────┤ +│ 0 │ true │ +│ 1 │ true │ +│ 2 │ true │ +│ 3 │ true │ +│ 4 │ false │ +╰───┴───────────────╯ + +``` diff --git a/commands/docs/polars_is-in.md b/commands/docs/polars_is-in.md new file mode 100644 index 0000000000..83ffb71d1c --- /dev/null +++ b/commands/docs/polars_is-in.md @@ -0,0 +1,65 @@ +--- +title: polars is-in +categories: | + expression +version: 0.93.0 +expression: | + Creates an is-in expression or checks to see if the elements are contained in the right series +usage: | + Creates an is-in expression or checks to see if the elements are contained in the right series +feature: default +--- + + +# `polars is-in` for [expression](/commands/categories/expression.md) + +
Creates an is-in expression or checks to see if the elements are contained in the right series
+ +## Signature + +```> polars is-in {flags} (list)``` + +## Parameters + + - `list`: List to check if values are in + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates a is-in expression +```nu +> let df = ([[a b]; [one 1] [two 2] [three 3]] | polars into-df); + $df | polars with-column (polars col a | polars is-in [one two] | polars as a_in) +╭───┬───────┬───┬───────╮ +│ # │ a │ b │ a_in │ +├───┼───────┼───┼───────┤ +│ 0 │ one │ 1 │ true │ +│ 1 │ two │ 2 │ true │ +│ 2 │ three │ 3 │ false │ +╰───┴───────┴───┴───────╯ + +``` + +Checks if elements from a series are contained in right series +```nu +> let other = ([1 3 6] | polars into-df); + [5 6 6 6 8 8 8] | polars into-df | polars is-in $other +╭───┬───────╮ +│ # │ is_in │ +├───┼───────┤ +│ 0 │ false │ +│ 1 │ true │ +│ 2 │ true │ +│ 3 │ true │ +│ 4 │ false │ +│ 5 │ false │ +│ 6 │ false │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_is-not-null.md b/commands/docs/polars_is-not-null.md new file mode 100644 index 0000000000..f106c79c9a --- /dev/null +++ b/commands/docs/polars_is-not-null.md @@ -0,0 +1,51 @@ +--- +title: polars is-not-null +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates mask where value is not null. +usage: | + Creates mask where value is not null. +feature: default +--- + + +# `polars is-not-null` for [dataframe](/commands/categories/dataframe.md) + +
Creates mask where value is not null.
+ +## Signature + +```> polars is-not-null {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create mask where values are not null +```nu +> let s = ([5 6 0 8] | polars into-df); + let res = ($s / $s); + $res | polars is-not-null +╭───┬─────────────╮ +│ # │ is_not_null │ +├───┼─────────────┤ +│ 0 │ true │ +│ 1 │ true │ +│ 2 │ false │ +│ 3 │ true │ +╰───┴─────────────╯ + +``` + +Creates a is not null expression from a column +```nu +> polars col a | polars is-not-null + +``` diff --git a/commands/docs/polars_is-null.md b/commands/docs/polars_is-null.md new file mode 100644 index 0000000000..ee07d14ce5 --- /dev/null +++ b/commands/docs/polars_is-null.md @@ -0,0 +1,51 @@ +--- +title: polars is-null +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates mask where value is null. +usage: | + Creates mask where value is null. +feature: default +--- + + +# `polars is-null` for [dataframe](/commands/categories/dataframe.md) + +
Creates mask where value is null.
+ +## Signature + +```> polars is-null {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create mask where values are null +```nu +> let s = ([5 6 0 8] | polars into-df); + let res = ($s / $s); + $res | polars is-null +╭───┬─────────╮ +│ # │ is_null │ +├───┼─────────┤ +│ 0 │ false │ +│ 1 │ false │ +│ 2 │ true │ +│ 3 │ false │ +╰───┴─────────╯ + +``` + +Creates a is null expression from a column +```nu +> polars col a | polars is-null + +``` diff --git a/commands/docs/polars_is-unique.md b/commands/docs/polars_is-unique.md new file mode 100644 index 0000000000..183c415338 --- /dev/null +++ b/commands/docs/polars_is-unique.md @@ -0,0 +1,61 @@ +--- +title: polars is-unique +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates mask indicating unique values. +usage: | + Creates mask indicating unique values. +feature: default +--- + + +# `polars is-unique` for [dataframe](/commands/categories/dataframe.md) + +
Creates mask indicating unique values.
+ +## Signature + +```> polars is-unique {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create mask indicating unique values +```nu +> [5 6 6 6 8 8 8] | polars into-df | polars is-unique +╭───┬───────────╮ +│ # │ is_unique │ +├───┼───────────┤ +│ 0 │ true │ +│ 1 │ false │ +│ 2 │ false │ +│ 3 │ false │ +│ 4 │ false │ +│ 5 │ false │ +│ 6 │ false │ +╰───┴───────────╯ + +``` + +Create mask indicating duplicated rows in a dataframe +```nu +> [[a, b]; [1 2] [1 2] [3 3] [3 3] [1 1]] | polars into-df | polars is-unique +╭───┬───────────╮ +│ # │ is_unique │ +├───┼───────────┤ +│ 0 │ false │ +│ 1 │ false │ +│ 2 │ false │ +│ 3 │ false │ +│ 4 │ true │ +╰───┴───────────╯ + +``` diff --git a/commands/docs/polars_join.md b/commands/docs/polars_join.md new file mode 100644 index 0000000000..3d23ea386d --- /dev/null +++ b/commands/docs/polars_join.md @@ -0,0 +1,75 @@ +--- +title: polars join +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Joins a lazy frame with other lazy frame. +usage: | + Joins a lazy frame with other lazy frame. +feature: default +--- + + +# `polars join` for [lazyframe](/commands/categories/lazyframe.md) + +
Joins a lazy frame with other lazy frame.
+ +## Signature + +```> polars join {flags} (other) (left_on) (right_on)``` + +## Flags + + - `--inner, -i`: inner joining between lazyframes (default) + - `--left, -l`: left join between lazyframes + - `--outer, -o`: outer join between lazyframes + - `--cross, -c`: cross join between lazyframes + - `--suffix, -s {string}`: Suffix to use on columns with same name + +## Parameters + + - `other`: LazyFrame to join with + - `left_on`: Left column(s) to join on + - `right_on`: Right column(s) to join on + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Join two lazy dataframes +```nu +> let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | polars into-lazy); + let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | polars into-lazy); + $df_a | polars join $df_b a foo | polars collect +╭───┬───┬───┬───┬─────┬─────╮ +│ # │ a │ b │ c │ bar │ ham │ +├───┼───┼───┼───┼─────┼─────┤ +│ 0 │ 1 │ a │ 0 │ a │ let │ +│ 1 │ 2 │ b │ 1 │ c │ var │ +│ 2 │ 1 │ c │ 2 │ a │ let │ +│ 3 │ 1 │ c │ 3 │ a │ let │ +╰───┴───┴───┴───┴─────┴─────╯ + +``` + +Join one eager dataframe with a lazy dataframe +```nu +> let df_a = ([[a b c];[1 "a" 0] [2 "b" 1] [1 "c" 2] [1 "c" 3]] | polars into-df); + let df_b = ([["foo" "bar" "ham"];[1 "a" "let"] [2 "c" "var"] [3 "c" "const"]] | polars into-lazy); + $df_a | polars join $df_b a foo +╭───┬───┬───┬───┬─────┬─────╮ +│ # │ a │ b │ c │ bar │ ham │ +├───┼───┼───┼───┼─────┼─────┤ +│ 0 │ 1 │ a │ 0 │ a │ let │ +│ 1 │ 2 │ b │ 1 │ c │ var │ +│ 2 │ 1 │ c │ 2 │ a │ let │ +│ 3 │ 1 │ c │ 3 │ a │ let │ +╰───┴───┴───┴───┴─────┴─────╯ + +``` diff --git a/commands/docs/polars_last.md b/commands/docs/polars_last.md new file mode 100644 index 0000000000..51cb2c3625 --- /dev/null +++ b/commands/docs/polars_last.md @@ -0,0 +1,50 @@ +--- +title: polars last +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates new dataframe with tail rows or creates a last expression. +usage: | + Creates new dataframe with tail rows or creates a last expression. +feature: default +--- + + +# `polars last` for [dataframe](/commands/categories/dataframe.md) + +
Creates new dataframe with tail rows or creates a last expression.
+ +## Signature + +```> polars last {flags} (rows)``` + +## Parameters + + - `rows`: Number of rows for tail + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create new dataframe with last rows +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars last 1 +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` + +Creates a last expression from a column +```nu +> polars col a | polars last + +``` diff --git a/commands/docs/polars_lit.md b/commands/docs/polars_lit.md new file mode 100644 index 0000000000..79cea7c5a4 --- /dev/null +++ b/commands/docs/polars_lit.md @@ -0,0 +1,42 @@ +--- +title: polars lit +categories: | + expression +version: 0.93.0 +expression: | + Creates a literal expression. +usage: | + Creates a literal expression. +feature: default +--- + + +# `polars lit` for [expression](/commands/categories/expression.md) + +
Creates a literal expression.
+ +## Signature + +```> polars lit {flags} (literal)``` + +## Parameters + + - `literal`: literal to construct the expression + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Created a literal expression and converts it to a nu object +```nu +> polars lit 2 | polars into-nu +╭───────┬─────────╮ +│ expr │ literal │ +│ value │ 2 │ +╰───────┴─────────╯ +``` diff --git a/commands/docs/polars_lowercase.md b/commands/docs/polars_lowercase.md new file mode 100644 index 0000000000..b1cd46d823 --- /dev/null +++ b/commands/docs/polars_lowercase.md @@ -0,0 +1,42 @@ +--- +title: polars lowercase +categories: | + dataframe +version: 0.93.0 +dataframe: | + Lowercase the strings in the column. +usage: | + Lowercase the strings in the column. +feature: default +--- + + +# `polars lowercase` for [dataframe](/commands/categories/dataframe.md) + +
Lowercase the strings in the column.
+ +## Signature + +```> polars lowercase {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Modifies strings to lowercase +```nu +> [Abc aBc abC] | polars into-df | polars lowercase +╭───┬─────╮ +│ # │ 0 │ +├───┼─────┤ +│ 0 │ abc │ +│ 1 │ abc │ +│ 2 │ abc │ +╰───┴─────╯ + +``` diff --git a/commands/docs/polars_max.md b/commands/docs/polars_max.md new file mode 100644 index 0000000000..3818f7251c --- /dev/null +++ b/commands/docs/polars_max.md @@ -0,0 +1,55 @@ +--- +title: polars max +categories: | + expression +version: 0.93.0 +expression: | + Creates a max expression or aggregates columns to their max value. +usage: | + Creates a max expression or aggregates columns to their max value. +feature: default +--- + + +# `polars max` for [expression](/commands/categories/expression.md) + +
Creates a max expression or aggregates columns to their max value.
+ +## Signature + +```> polars max {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Max value from columns in a dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] | polars into-df | polars max +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 6 │ 4 │ +╰───┴───┴───╯ + +``` + +Max aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars max) +╭───┬─────┬───╮ +│ # │ a │ b │ +├───┼─────┼───┤ +│ 0 │ one │ 4 │ +│ 1 │ two │ 1 │ +╰───┴─────┴───╯ + +``` diff --git a/commands/docs/polars_mean.md b/commands/docs/polars_mean.md new file mode 100644 index 0000000000..0bcba105ab --- /dev/null +++ b/commands/docs/polars_mean.md @@ -0,0 +1,55 @@ +--- +title: polars mean +categories: | + expression +version: 0.93.0 +expression: | + Creates a mean expression for an aggregation or aggregates columns to their mean value. +usage: | + Creates a mean expression for an aggregation or aggregates columns to their mean value. +feature: default +--- + + +# `polars mean` for [expression](/commands/categories/expression.md) + +
Creates a mean expression for an aggregation or aggregates columns to their mean value.
+ +## Signature + +```> polars mean {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Mean value from columns in a dataframe +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars mean +╭───┬──────┬──────╮ +│ # │ a │ b │ +├───┼──────┼──────┤ +│ 0 │ 4.00 │ 2.00 │ +╰───┴──────┴──────╯ + +``` + +Mean aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars mean) +╭───┬─────┬──────╮ +│ # │ a │ b │ +├───┼─────┼──────┤ +│ 0 │ one │ 3.00 │ +│ 1 │ two │ 1.00 │ +╰───┴─────┴──────╯ + +``` diff --git a/commands/docs/polars_median.md b/commands/docs/polars_median.md new file mode 100644 index 0000000000..b0102396f7 --- /dev/null +++ b/commands/docs/polars_median.md @@ -0,0 +1,55 @@ +--- +title: polars median +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Median value from columns in a dataframe or creates expression for an aggregation +usage: | + Median value from columns in a dataframe or creates expression for an aggregation +feature: default +--- + + +# `polars median` for [lazyframe](/commands/categories/lazyframe.md) + +
Median value from columns in a dataframe or creates expression for an aggregation
+ +## Signature + +```> polars median {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Median aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars median) +╭───┬─────┬──────╮ +│ # │ a │ b │ +├───┼─────┼──────┤ +│ 0 │ one │ 3.00 │ +│ 1 │ two │ 1.00 │ +╰───┴─────┴──────╯ + +``` + +Median value from columns in a dataframe +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars median +╭───┬──────┬──────╮ +│ # │ a │ b │ +├───┼──────┼──────┤ +│ 0 │ 4.00 │ 2.00 │ +╰───┴──────┴──────╯ + +``` diff --git a/commands/docs/polars_melt.md b/commands/docs/polars_melt.md new file mode 100644 index 0000000000..e3d24dc32d --- /dev/null +++ b/commands/docs/polars_melt.md @@ -0,0 +1,52 @@ +--- +title: polars melt +categories: | + dataframe +version: 0.93.0 +dataframe: | + Unpivot a DataFrame from wide to long format. +usage: | + Unpivot a DataFrame from wide to long format. +feature: default +--- + + +# `polars melt` for [dataframe](/commands/categories/dataframe.md) + +
Unpivot a DataFrame from wide to long format.
+ +## Signature + +```> polars melt {flags} ``` + +## Flags + + - `--columns, -c {table}`: column names for melting + - `--values, -v {table}`: column names used as value columns + - `--variable-name, -r {string}`: optional name for variable column + - `--value-name, -l {string}`: optional name for value column + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +melt dataframe +```nu +> [[a b c d]; [x 1 4 a] [y 2 5 b] [z 3 6 c]] | polars into-df | polars melt -c [b c] -v [a d] +╭───┬───┬───┬──────────┬───────╮ +│ # │ b │ c │ variable │ value │ +├───┼───┼───┼──────────┼───────┤ +│ 0 │ 1 │ 4 │ a │ x │ +│ 1 │ 2 │ 5 │ a │ y │ +│ 2 │ 3 │ 6 │ a │ z │ +│ 3 │ 1 │ 4 │ d │ a │ +│ 4 │ 2 │ 5 │ d │ b │ +│ 5 │ 3 │ 6 │ d │ c │ +╰───┴───┴───┴──────────┴───────╯ + +``` diff --git a/commands/docs/polars_min.md b/commands/docs/polars_min.md new file mode 100644 index 0000000000..8577e4b69e --- /dev/null +++ b/commands/docs/polars_min.md @@ -0,0 +1,55 @@ +--- +title: polars min +categories: | + expression +version: 0.93.0 +expression: | + Creates a min expression or aggregates columns to their min value. +usage: | + Creates a min expression or aggregates columns to their min value. +feature: default +--- + + +# `polars min` for [expression](/commands/categories/expression.md) + +
Creates a min expression or aggregates columns to their min value.
+ +## Signature + +```> polars min {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Min value from columns in a dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] | polars into-df | polars min +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 1 │ +╰───┴───┴───╯ + +``` + +Min aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars min) +╭───┬─────┬───╮ +│ # │ a │ b │ +├───┼─────┼───┤ +│ 0 │ one │ 2 │ +│ 1 │ two │ 1 │ +╰───┴─────┴───╯ + +``` diff --git a/commands/docs/polars_n-unique.md b/commands/docs/polars_n-unique.md new file mode 100644 index 0000000000..fc26efc47f --- /dev/null +++ b/commands/docs/polars_n-unique.md @@ -0,0 +1,46 @@ +--- +title: polars n-unique +categories: | + dataframe +version: 0.93.0 +dataframe: | + Counts unique values. +usage: | + Counts unique values. +feature: default +--- + + +# `polars n-unique` for [dataframe](/commands/categories/dataframe.md) + +
Counts unique values.
+ +## Signature + +```> polars n-unique {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Counts unique values +```nu +> [1 1 2 2 3 3 4] | polars into-df | polars n-unique +╭───┬──────────────╮ +│ # │ count_unique │ +├───┼──────────────┤ +│ 0 │ 4 │ +╰───┴──────────────╯ + +``` + +Creates a is n-unique expression from a column +```nu +> polars col a | polars n-unique + +``` diff --git a/commands/docs/polars_not.md b/commands/docs/polars_not.md new file mode 100644 index 0000000000..50a59f33a3 --- /dev/null +++ b/commands/docs/polars_not.md @@ -0,0 +1,42 @@ +--- +title: polars not +categories: | + dataframe +version: 0.93.0 +dataframe: | + Inverts boolean mask. +usage: | + Inverts boolean mask. +feature: default +--- + + +# `polars not` for [dataframe](/commands/categories/dataframe.md) + +
Inverts boolean mask.
+ +## Signature + +```> polars not {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Inverts boolean mask +```nu +> [true false true] | polars into-df | polars not +╭───┬───────╮ +│ # │ 0 │ +├───┼───────┤ +│ 0 │ false │ +│ 1 │ true │ +│ 2 │ false │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_open.md b/commands/docs/polars_open.md new file mode 100644 index 0000000000..73cc5cc3ed --- /dev/null +++ b/commands/docs/polars_open.md @@ -0,0 +1,50 @@ +--- +title: polars open +categories: | + dataframe +version: 0.93.0 +dataframe: | + Opens CSV, JSON, JSON lines, arrow, avro, or parquet file to create dataframe. +usage: | + Opens CSV, JSON, JSON lines, arrow, avro, or parquet file to create dataframe. +feature: default +--- + + +# `polars open` for [dataframe](/commands/categories/dataframe.md) + +
Opens CSV, JSON, JSON lines, arrow, avro, or parquet file to create dataframe.
+ +## Signature + +```> polars open {flags} (file)``` + +## Flags + + - `--lazy, -l`: creates a lazy dataframe + - `--type, -t {string}`: File type: csv, tsv, json, parquet, arrow, avro. If omitted, derive from file extension + - `--delimiter, -d {string}`: file delimiter character. CSV file + - `--no-header, -`: Indicates if file doesn't have header. CSV file + - `--infer-schema, - {number}`: Number of rows to infer the schema of the file. CSV file + - `--skip-rows, - {number}`: Number of rows to skip from file. CSV file + - `--columns, - {list}`: Columns to be selected from csv file. CSV and Parquet file + - `--schema, -s {record}`: Polars Schema in format [{name: str}]. CSV, JSON, and JSONL files + +## Parameters + + - `file`: file path to load values from + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Takes a file name and creates a dataframe +```nu +> polars open test.csv + +``` diff --git a/commands/docs/polars_otherwise.md b/commands/docs/polars_otherwise.md new file mode 100644 index 0000000000..3596059311 --- /dev/null +++ b/commands/docs/polars_otherwise.md @@ -0,0 +1,66 @@ +--- +title: polars otherwise +categories: | + expression +version: 0.93.0 +expression: | + Completes a when expression. +usage: | + Completes a when expression. +feature: default +--- + + +# `polars otherwise` for [expression](/commands/categories/expression.md) + +
Completes a when expression.
+ +## Signature + +```> polars otherwise {flags} (otherwise expression)``` + +## Parameters + + - `otherwise expression`: expression to apply when no when predicate matches + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create a when conditions +```nu +> polars when ((polars col a) > 2) 4 | polars otherwise 5 + +``` + +Create a when conditions +```nu +> polars when ((polars col a) > 2) 4 | polars when ((polars col a) < 0) 6 | polars otherwise 0 + +``` + +Create a new column for the dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] + | polars into-lazy + | polars with-column ( + polars when ((polars col a) > 2) 4 | polars otherwise 5 | polars as c + ) + | polars with-column ( + polars when ((polars col a) > 5) 10 | polars when ((polars col a) < 2) 6 | polars otherwise 0 | polars as d + ) + | polars collect +╭───┬───┬───┬───┬────╮ +│ # │ a │ b │ c │ d │ +├───┼───┼───┼───┼────┤ +│ 0 │ 6 │ 2 │ 4 │ 10 │ +│ 1 │ 1 │ 4 │ 5 │ 6 │ +│ 2 │ 4 │ 1 │ 4 │ 0 │ +╰───┴───┴───┴───┴────╯ + +``` diff --git a/commands/docs/polars_quantile.md b/commands/docs/polars_quantile.md new file mode 100644 index 0000000000..a10e133e45 --- /dev/null +++ b/commands/docs/polars_quantile.md @@ -0,0 +1,59 @@ +--- +title: polars quantile +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Aggregates the columns to the selected quantile. +usage: | + Aggregates the columns to the selected quantile. +feature: default +--- + + +# `polars quantile` for [lazyframe](/commands/categories/lazyframe.md) + +
Aggregates the columns to the selected quantile.
+ +## Signature + +```> polars quantile {flags} (quantile)``` + +## Parameters + + - `quantile`: quantile value for quantile operation + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +quantile value from columns in a dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] | polars into-df | polars quantile 0.5 +╭───┬──────┬──────╮ +│ # │ a │ b │ +├───┼──────┼──────┤ +│ 0 │ 4.00 │ 2.00 │ +╰───┴──────┴──────╯ + +``` + +Quantile aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars quantile 0.5) +╭───┬─────┬──────╮ +│ # │ a │ b │ +├───┼─────┼──────┤ +│ 0 │ one │ 4.00 │ +│ 1 │ two │ 1.00 │ +╰───┴─────┴──────╯ + +``` diff --git a/commands/docs/polars_query.md b/commands/docs/polars_query.md new file mode 100644 index 0000000000..8dc60ca9a0 --- /dev/null +++ b/commands/docs/polars_query.md @@ -0,0 +1,45 @@ +--- +title: polars query +categories: | + dataframe +version: 0.93.0 +dataframe: | + Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause. +usage: | + Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause. +feature: default +--- + + +# `polars query` for [dataframe](/commands/categories/dataframe.md) + +
Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause.
+ +## Signature + +```> polars query {flags} (sql)``` + +## Parameters + + - `sql`: sql query + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Query dataframe using SQL +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars query 'select a from df' +╭───┬───╮ +│ # │ a │ +├───┼───┤ +│ 0 │ 1 │ +│ 1 │ 3 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_rename.md b/commands/docs/polars_rename.md new file mode 100644 index 0000000000..cda763ce22 --- /dev/null +++ b/commands/docs/polars_rename.md @@ -0,0 +1,72 @@ +--- +title: polars rename +categories: | + dataframe or lazyframe +version: 0.93.0 +dataframe_or_lazyframe: | + Rename a dataframe column. +usage: | + Rename a dataframe column. +feature: default +--- + + +# `polars rename` for [dataframe or lazyframe](/commands/categories/dataframe or lazyframe.md) + +
Rename a dataframe column.
+ +## Signature + +```> polars rename {flags} (columns) (new names)``` + +## Parameters + + - `columns`: Column(s) to be renamed. A string or list of strings + - `new names`: New names for the selected column(s). A string or list of strings + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Renames a series +```nu +> [5 6 7 8] | polars into-df | polars rename '0' new_name +╭───┬──────────╮ +│ # │ new_name │ +├───┼──────────┤ +│ 0 │ 5 │ +│ 1 │ 6 │ +│ 2 │ 7 │ +│ 3 │ 8 │ +╰───┴──────────╯ + +``` + +Renames a dataframe column +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars rename a a_new +╭───┬───────┬───╮ +│ # │ a_new │ b │ +├───┼───────┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───────┴───╯ + +``` + +Renames two dataframe columns +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars rename [a b] [a_new b_new] +╭───┬───────┬───────╮ +│ # │ a_new │ b_new │ +├───┼───────┼───────┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───────┴───────╯ + +``` diff --git a/commands/docs/polars_replace-all.md b/commands/docs/polars_replace-all.md new file mode 100644 index 0000000000..c085e99db4 --- /dev/null +++ b/commands/docs/polars_replace-all.md @@ -0,0 +1,47 @@ +--- +title: polars replace-all +categories: | + dataframe +version: 0.93.0 +dataframe: | + Replace all (sub)strings by a regex pattern. +usage: | + Replace all (sub)strings by a regex pattern. +feature: default +--- + + +# `polars replace-all` for [dataframe](/commands/categories/dataframe.md) + +
Replace all (sub)strings by a regex pattern.
+ +## Signature + +```> polars replace-all {flags} ``` + +## Flags + + - `--pattern, -p {string}`: Regex pattern to be matched + - `--replace, -r {string}`: replacing string + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Replaces string +```nu +> [abac abac abac] | polars into-df | polars replace-all --pattern a --replace A +╭───┬──────╮ +│ # │ 0 │ +├───┼──────┤ +│ 0 │ AbAc │ +│ 1 │ AbAc │ +│ 2 │ AbAc │ +╰───┴──────╯ + +``` diff --git a/commands/docs/polars_replace.md b/commands/docs/polars_replace.md new file mode 100644 index 0000000000..e1ba4e0b3a --- /dev/null +++ b/commands/docs/polars_replace.md @@ -0,0 +1,47 @@ +--- +title: polars replace +categories: | + dataframe +version: 0.93.0 +dataframe: | + Replace the leftmost (sub)string by a regex pattern. +usage: | + Replace the leftmost (sub)string by a regex pattern. +feature: default +--- + + +# `polars replace` for [dataframe](/commands/categories/dataframe.md) + +
Replace the leftmost (sub)string by a regex pattern.
+ +## Signature + +```> polars replace {flags} ``` + +## Flags + + - `--pattern, -p {string}`: Regex pattern to be matched + - `--replace, -r {string}`: replacing string + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Replaces string +```nu +> [abc abc abc] | polars into-df | polars replace --pattern ab --replace AB +╭───┬─────╮ +│ # │ 0 │ +├───┼─────┤ +│ 0 │ ABc │ +│ 1 │ ABc │ +│ 2 │ ABc │ +╰───┴─────╯ + +``` diff --git a/commands/docs/polars_reverse.md b/commands/docs/polars_reverse.md new file mode 100644 index 0000000000..0582feac98 --- /dev/null +++ b/commands/docs/polars_reverse.md @@ -0,0 +1,42 @@ +--- +title: polars reverse +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Reverses the LazyFrame +usage: | + Reverses the LazyFrame +feature: default +--- + + +# `polars reverse` for [lazyframe](/commands/categories/lazyframe.md) + +
Reverses the LazyFrame
+ +## Signature + +```> polars reverse {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Reverses the dataframe. +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars reverse +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 2 │ 2 │ +│ 1 │ 4 │ 2 │ +│ 2 │ 6 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_rolling.md b/commands/docs/polars_rolling.md new file mode 100644 index 0000000000..98cbb3a38b --- /dev/null +++ b/commands/docs/polars_rolling.md @@ -0,0 +1,62 @@ +--- +title: polars rolling +categories: | + dataframe +version: 0.93.0 +dataframe: | + Rolling calculation for a series. +usage: | + Rolling calculation for a series. +feature: default +--- + + +# `polars rolling` for [dataframe](/commands/categories/dataframe.md) + +
Rolling calculation for a series.
+ +## Signature + +```> polars rolling {flags} (type) (window)``` + +## Parameters + + - `type`: rolling operation + - `window`: Window size for rolling + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Rolling sum for a series +```nu +> [1 2 3 4 5] | polars into-df | polars rolling sum 2 | polars drop-nulls +╭───┬───────────────╮ +│ # │ 0_rolling_sum │ +├───┼───────────────┤ +│ 0 │ 3 │ +│ 1 │ 5 │ +│ 2 │ 7 │ +│ 3 │ 9 │ +╰───┴───────────────╯ + +``` + +Rolling max for a series +```nu +> [1 2 3 4 5] | polars into-df | polars rolling max 2 | polars drop-nulls +╭───┬───────────────╮ +│ # │ 0_rolling_max │ +├───┼───────────────┤ +│ 0 │ 2 │ +│ 1 │ 3 │ +│ 2 │ 4 │ +│ 3 │ 5 │ +╰───┴───────────────╯ + +``` diff --git a/commands/docs/polars_sample.md b/commands/docs/polars_sample.md new file mode 100644 index 0000000000..02da433a4a --- /dev/null +++ b/commands/docs/polars_sample.md @@ -0,0 +1,49 @@ +--- +title: polars sample +categories: | + dataframe +version: 0.93.0 +dataframe: | + Create sample dataframe. +usage: | + Create sample dataframe. +feature: default +--- + + +# `polars sample` for [dataframe](/commands/categories/dataframe.md) + +
Create sample dataframe.
+ +## Signature + +```> polars sample {flags} ``` + +## Flags + + - `--n-rows, -n {int}`: number of rows to be taken from dataframe + - `--fraction, -f {number}`: fraction of dataframe to be taken + - `--seed, -s {number}`: seed for the selection + - `--replace, -e`: sample with replace + - `--shuffle, -u`: shuffle sample + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Sample rows from dataframe +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars sample --n-rows 1 + +``` + +Shows sample row using fraction and replace +```nu +> [[a b]; [1 2] [3 4] [5 6]] | polars into-df | polars sample --fraction 0.5 --replace + +``` diff --git a/commands/docs/polars_schema.md b/commands/docs/polars_schema.md new file mode 100644 index 0000000000..52f87b648b --- /dev/null +++ b/commands/docs/polars_schema.md @@ -0,0 +1,42 @@ +--- +title: polars schema +categories: | + dataframe +version: 0.93.0 +dataframe: | + Show schema for a dataframe. +usage: | + Show schema for a dataframe. +feature: default +--- + + +# `polars schema` for [dataframe](/commands/categories/dataframe.md) + +
Show schema for a dataframe.
+ +## Signature + +```> polars schema {flags} ``` + +## Flags + + - `--datatype-list, -l`: creates a lazy dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Dataframe schema +```nu +> [[a b]; [1 "foo"] [3 "bar"]] | polars into-df | polars schema +╭───┬─────╮ +│ a │ i64 │ +│ b │ str │ +╰───┴─────╯ +``` diff --git a/commands/docs/polars_select.md b/commands/docs/polars_select.md new file mode 100644 index 0000000000..2459cc0f13 --- /dev/null +++ b/commands/docs/polars_select.md @@ -0,0 +1,46 @@ +--- +title: polars select +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Selects columns from lazyframe. +usage: | + Selects columns from lazyframe. +feature: default +--- + + +# `polars select` for [lazyframe](/commands/categories/lazyframe.md) + +
Selects columns from lazyframe.
+ +## Signature + +```> polars select {flags} ...rest``` + +## Parameters + + - `...rest`: Expression(s) that define the column selection + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Select a column from the dataframe +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars select a +╭───┬───╮ +│ # │ a │ +├───┼───┤ +│ 0 │ 6 │ +│ 1 │ 4 │ +│ 2 │ 2 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_set-with-idx.md b/commands/docs/polars_set-with-idx.md new file mode 100644 index 0000000000..10f8d62e76 --- /dev/null +++ b/commands/docs/polars_set-with-idx.md @@ -0,0 +1,55 @@ +--- +title: polars set-with-idx +categories: | + dataframe +version: 0.93.0 +dataframe: | + Sets value in the given index. +usage: | + Sets value in the given index. +feature: default +--- + + +# `polars set-with-idx` for [dataframe](/commands/categories/dataframe.md) + +
Sets value in the given index.
+ +## Signature + +```> polars set-with-idx {flags} (value)``` + +## Flags + + - `--indices, -i {any}`: list of indices indicating where to set the value + +## Parameters + + - `value`: value to be inserted in series + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Set value in selected rows from series +```nu +> let series = ([4 1 5 2 4 3] | polars into-df); + let indices = ([0 2] | polars into-df); + $series | polars set-with-idx 6 --indices $indices +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 6 │ +│ 1 │ 1 │ +│ 2 │ 6 │ +│ 3 │ 2 │ +│ 4 │ 4 │ +│ 5 │ 3 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_set.md b/commands/docs/polars_set.md new file mode 100644 index 0000000000..51edabd48f --- /dev/null +++ b/commands/docs/polars_set.md @@ -0,0 +1,54 @@ +--- +title: polars set +categories: | + dataframe +version: 0.93.0 +dataframe: | + Sets value where given mask is true. +usage: | + Sets value where given mask is true. +feature: default +--- + + +# `polars set` for [dataframe](/commands/categories/dataframe.md) + +
Sets value where given mask is true.
+ +## Signature + +```> polars set {flags} (value)``` + +## Flags + + - `--mask, -m {any}`: mask indicating insertions + +## Parameters + + - `value`: value to be inserted in series + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Shifts the values by a given period +```nu +> let s = ([1 2 2 3 3] | polars into-df | polars shift 2); + let mask = ($s | polars is-null); + $s | polars set 0 --mask $mask +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 0 │ +│ 1 │ 0 │ +│ 2 │ 1 │ +│ 3 │ 2 │ +│ 4 │ 2 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_shape.md b/commands/docs/polars_shape.md new file mode 100644 index 0000000000..ff73b64404 --- /dev/null +++ b/commands/docs/polars_shape.md @@ -0,0 +1,40 @@ +--- +title: polars shape +categories: | + dataframe +version: 0.93.0 +dataframe: | + Shows column and row size for a dataframe. +usage: | + Shows column and row size for a dataframe. +feature: default +--- + + +# `polars shape` for [dataframe](/commands/categories/dataframe.md) + +
Shows column and row size for a dataframe.
+ +## Signature + +```> polars shape {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Shows row and column shape +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars shape +╭───┬──────┬─────────╮ +│ # │ rows │ columns │ +├───┼──────┼─────────┤ +│ 0 │ 2 │ 2 │ +╰───┴──────┴─────────╯ + +``` diff --git a/commands/docs/polars_shift.md b/commands/docs/polars_shift.md new file mode 100644 index 0000000000..8c8c3a4fff --- /dev/null +++ b/commands/docs/polars_shift.md @@ -0,0 +1,50 @@ +--- +title: polars shift +categories: | + dataframe or lazyframe +version: 0.93.0 +dataframe_or_lazyframe: | + Shifts the values by a given period. +usage: | + Shifts the values by a given period. +feature: default +--- + + +# `polars shift` for [dataframe or lazyframe](/commands/categories/dataframe or lazyframe.md) + +
Shifts the values by a given period.
+ +## Signature + +```> polars shift {flags} (period)``` + +## Flags + + - `--fill, -f {any}`: Expression used to fill the null values (lazy df) + +## Parameters + + - `period`: shift period + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Shifts the values by a given period +```nu +> [1 2 2 3 3] | polars into-df | polars shift 2 | polars drop-nulls +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 1 │ +│ 1 │ 2 │ +│ 2 │ 2 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_slice.md b/commands/docs/polars_slice.md new file mode 100644 index 0000000000..d2a758507b --- /dev/null +++ b/commands/docs/polars_slice.md @@ -0,0 +1,45 @@ +--- +title: polars slice +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates new dataframe from a slice of rows. +usage: | + Creates new dataframe from a slice of rows. +feature: default +--- + + +# `polars slice` for [dataframe](/commands/categories/dataframe.md) + +
Creates new dataframe from a slice of rows.
+ +## Signature + +```> polars slice {flags} (offset) (size)``` + +## Parameters + + - `offset`: start of slice + - `size`: size of slice + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create new dataframe from a slice of the rows +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars slice 0 1 +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_sort-by.md b/commands/docs/polars_sort-by.md new file mode 100644 index 0000000000..aa86180299 --- /dev/null +++ b/commands/docs/polars_sort-by.md @@ -0,0 +1,66 @@ +--- +title: polars sort-by +categories: | + lazyframe +version: 0.93.0 +lazyframe: | + Sorts a lazy dataframe based on expression(s). +usage: | + Sorts a lazy dataframe based on expression(s). +feature: default +--- + + +# `polars sort-by` for [lazyframe](/commands/categories/lazyframe.md) + +
Sorts a lazy dataframe based on expression(s).
+ +## Signature + +```> polars sort-by {flags} ...rest``` + +## Flags + + - `--reverse, -r {list}`: Reverse sorting. Default is false + - `--nulls-last, -n`: nulls are shown last in the dataframe + - `--maintain-order, -m`: Maintains order during sort + +## Parameters + + - `...rest`: sort expression for the dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Sort dataframe by one column +```nu +> [[a b]; [6 2] [1 4] [4 1]] | polars into-df | polars sort-by a +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 4 │ +│ 1 │ 4 │ 1 │ +│ 2 │ 6 │ 2 │ +╰───┴───┴───╯ + +``` + +Sort column using two columns +```nu +> [[a b]; [6 2] [1 1] [1 4] [2 4]] | polars into-df | polars sort-by [a b] -r [false true] +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 4 │ +│ 1 │ 1 │ 1 │ +│ 2 │ 2 │ 4 │ +│ 3 │ 6 │ 2 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_std.md b/commands/docs/polars_std.md new file mode 100644 index 0000000000..52ef7606c9 --- /dev/null +++ b/commands/docs/polars_std.md @@ -0,0 +1,55 @@ +--- +title: polars std +categories: | + expression +version: 0.93.0 +expression: | + Creates a std expression for an aggregation of std value from columns in a dataframe. +usage: | + Creates a std expression for an aggregation of std value from columns in a dataframe. +feature: default +--- + + +# `polars std` for [expression](/commands/categories/expression.md) + +
Creates a std expression for an aggregation of std value from columns in a dataframe.
+ +## Signature + +```> polars std {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Std value from columns in a dataframe +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars std +╭───┬──────┬──────╮ +│ # │ a │ b │ +├───┼──────┼──────┤ +│ 0 │ 2.00 │ 0.00 │ +╰───┴──────┴──────╯ + +``` + +Std aggregation for a group-by +```nu +> [[a b]; [one 2] [one 2] [two 1] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars std) +╭───┬─────┬──────╮ +│ # │ a │ b │ +├───┼─────┼──────┤ +│ 0 │ one │ 0.00 │ +│ 1 │ two │ 0.00 │ +╰───┴─────┴──────╯ + +``` diff --git a/commands/docs/polars_store-get.md b/commands/docs/polars_store-get.md new file mode 100644 index 0000000000..7ed3611b37 --- /dev/null +++ b/commands/docs/polars_store-get.md @@ -0,0 +1,46 @@ +--- +title: polars store-get +categories: | + dataframe +version: 0.93.0 +dataframe: | + Gets a Dataframe or other object from the plugin cache. +usage: | + Gets a Dataframe or other object from the plugin cache. +feature: default +--- + + +# `polars store-get` for [dataframe](/commands/categories/dataframe.md) + +
Gets a Dataframe or other object from the plugin cache.
+ +## Signature + +```> polars store-get {flags} (key)``` + +## Parameters + + - `key`: Key of objects to get + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Get a stored object +```nu +> let df = ([[a b];[1 2] [3 4]] | polars into-df); + polars store-ls | get key | first | polars store-get $in +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 1 │ 2 │ +│ 1 │ 3 │ 4 │ +╰───┴───┴───╯ + +``` diff --git a/commands/docs/polars_store-ls.md b/commands/docs/polars_store-ls.md new file mode 100644 index 0000000000..7a5ca2fbd6 --- /dev/null +++ b/commands/docs/polars_store-ls.md @@ -0,0 +1,36 @@ +--- +title: polars store-ls +categories: | + dataframe +version: 0.93.0 +dataframe: | + Lists stored dataframes. +usage: | + Lists stored dataframes. +feature: default +--- + + +# `polars store-ls` for [dataframe](/commands/categories/dataframe.md) + +
Lists stored dataframes.
+ +## Signature + +```> polars store-ls {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates a new dataframe and shows it in the dataframe list +```nu +> let test = ([[a b];[1 2] [3 4]] | polars into-df); + polars store-ls + +``` diff --git a/commands/docs/polars_store-rm.md b/commands/docs/polars_store-rm.md new file mode 100644 index 0000000000..7d897e114a --- /dev/null +++ b/commands/docs/polars_store-rm.md @@ -0,0 +1,40 @@ +--- +title: polars store-rm +categories: | + dataframe +version: 0.93.0 +dataframe: | + Removes a stored Dataframe or other object from the plugin cache. +usage: | + Removes a stored Dataframe or other object from the plugin cache. +feature: default +--- + + +# `polars store-rm` for [dataframe](/commands/categories/dataframe.md) + +
Removes a stored Dataframe or other object from the plugin cache.
+ +## Signature + +```> polars store-rm {flags} ...rest``` + +## Parameters + + - `...rest`: Keys of objects to remove + + +## Input/output types: + +| input | output | +| ----- | ------------ | +| any | list\ | + +## Examples + +Removes a stored +```nu +> let df = ([[a b];[1 2] [3 4]] | polars into-df); + polars store-ls | get key | first | polars store-rm $in + +``` diff --git a/commands/docs/polars_str-lengths.md b/commands/docs/polars_str-lengths.md new file mode 100644 index 0000000000..94adbfc770 --- /dev/null +++ b/commands/docs/polars_str-lengths.md @@ -0,0 +1,42 @@ +--- +title: polars str-lengths +categories: | + dataframe +version: 0.93.0 +dataframe: | + Get lengths of all strings. +usage: | + Get lengths of all strings. +feature: default +--- + + +# `polars str-lengths` for [dataframe](/commands/categories/dataframe.md) + +
Get lengths of all strings.
+ +## Signature + +```> polars str-lengths {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns string lengths +```nu +> [a ab abc] | polars into-df | polars str-lengths +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 1 │ +│ 1 │ 2 │ +│ 2 │ 3 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_str-slice.md b/commands/docs/polars_str-slice.md new file mode 100644 index 0000000000..d2f8470cee --- /dev/null +++ b/commands/docs/polars_str-slice.md @@ -0,0 +1,63 @@ +--- +title: polars str-slice +categories: | + dataframe +version: 0.93.0 +dataframe: | + Slices the string from the start position until the selected length. +usage: | + Slices the string from the start position until the selected length. +feature: default +--- + + +# `polars str-slice` for [dataframe](/commands/categories/dataframe.md) + +
Slices the string from the start position until the selected length.
+ +## Signature + +```> polars str-slice {flags} (start)``` + +## Flags + + - `--length, -l {int}`: optional length + +## Parameters + + - `start`: start of slice + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Creates slices from the strings +```nu +> [abcded abc321 abc123] | polars into-df | polars str-slice 1 --length 2 +╭───┬────╮ +│ # │ 0 │ +├───┼────┤ +│ 0 │ bc │ +│ 1 │ bc │ +│ 2 │ bc │ +╰───┴────╯ + +``` + +Creates slices from the strings without length +```nu +> [abcded abc321 abc123] | polars into-df | polars str-slice 1 +╭───┬───────╮ +│ # │ 0 │ +├───┼───────┤ +│ 0 │ bcded │ +│ 1 │ bc321 │ +│ 2 │ bc123 │ +╰───┴───────╯ + +``` diff --git a/commands/docs/polars_strftime.md b/commands/docs/polars_strftime.md new file mode 100644 index 0000000000..abc0d5e76f --- /dev/null +++ b/commands/docs/polars_strftime.md @@ -0,0 +1,47 @@ +--- +title: polars strftime +categories: | + dataframe +version: 0.93.0 +dataframe: | + Formats date based on string rule. +usage: | + Formats date based on string rule. +feature: default +--- + + +# `polars strftime` for [dataframe](/commands/categories/dataframe.md) + +
Formats date based on string rule.
+ +## Signature + +```> polars strftime {flags} (fmt)``` + +## Parameters + + - `fmt`: Format rule + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Formats date +```nu +> let dt = ('2020-08-04T16:39:18+00:00' | into datetime --timezone 'UTC'); + let df = ([$dt $dt] | polars into-df); + $df | polars strftime "%Y/%m/%d" +╭───┬────────────╮ +│ # │ 0 │ +├───┼────────────┤ +│ 0 │ 2020/08/04 │ +│ 1 │ 2020/08/04 │ +╰───┴────────────╯ + +``` diff --git a/commands/docs/polars_sum.md b/commands/docs/polars_sum.md new file mode 100644 index 0000000000..a29a7bbe9a --- /dev/null +++ b/commands/docs/polars_sum.md @@ -0,0 +1,55 @@ +--- +title: polars sum +categories: | + expression +version: 0.93.0 +expression: | + Creates a sum expression for an aggregation or aggregates columns to their sum value. +usage: | + Creates a sum expression for an aggregation or aggregates columns to their sum value. +feature: default +--- + + +# `polars sum` for [expression](/commands/categories/expression.md) + +
Creates a sum expression for an aggregation or aggregates columns to their sum value.
+ +## Signature + +```> polars sum {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Sums all columns in a dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] | polars into-df | polars sum +╭───┬────┬───╮ +│ # │ a │ b │ +├───┼────┼───┤ +│ 0 │ 11 │ 7 │ +╰───┴────┴───╯ + +``` + +Sum aggregation for a group-by +```nu +> [[a b]; [one 2] [one 4] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars sum) +╭───┬─────┬───╮ +│ # │ a │ b │ +├───┼─────┼───┤ +│ 0 │ one │ 6 │ +│ 1 │ two │ 1 │ +╰───┴─────┴───╯ + +``` diff --git a/commands/docs/polars_summary.md b/commands/docs/polars_summary.md new file mode 100644 index 0000000000..8dcb8642b1 --- /dev/null +++ b/commands/docs/polars_summary.md @@ -0,0 +1,53 @@ +--- +title: polars summary +categories: | + dataframe +version: 0.93.0 +dataframe: | + For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns. +usage: | + For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns. +feature: default +--- + + +# `polars summary` for [dataframe](/commands/categories/dataframe.md) + +
For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns.
+ +## Signature + +```> polars summary {flags} ``` + +## Flags + + - `--quantiles, -q {table}`: provide optional quantiles + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +list dataframe descriptives +```nu +> [[a b]; [1 1] [1 1]] | polars into-df | polars summary +╭───┬────────────┬─────────┬─────────╮ +│ # │ descriptor │ a (i64) │ b (i64) │ +├───┼────────────┼─────────┼─────────┤ +│ 0 │ count │ 2.00 │ 2.00 │ +│ 1 │ sum │ 2.00 │ 2.00 │ +│ 2 │ mean │ 1.00 │ 1.00 │ +│ 3 │ median │ 1.00 │ 1.00 │ +│ 4 │ std │ 0.00 │ 0.00 │ +│ 5 │ min │ 1.00 │ 1.00 │ +│ 6 │ 25% │ 1.00 │ 1.00 │ +│ 7 │ 50% │ 1.00 │ 1.00 │ +│ 8 │ 75% │ 1.00 │ 1.00 │ +│ 9 │ max │ 1.00 │ 1.00 │ +╰───┴────────────┴─────────┴─────────╯ + +``` diff --git a/commands/docs/polars_take.md b/commands/docs/polars_take.md new file mode 100644 index 0000000000..eb2c5c75a4 --- /dev/null +++ b/commands/docs/polars_take.md @@ -0,0 +1,61 @@ +--- +title: polars take +categories: | + dataframe +version: 0.93.0 +dataframe: | + Creates new dataframe using the given indices. +usage: | + Creates new dataframe using the given indices. +feature: default +--- + + +# `polars take` for [dataframe](/commands/categories/dataframe.md) + +
Creates new dataframe using the given indices.
+ +## Signature + +```> polars take {flags} (indices)``` + +## Parameters + + - `indices`: list of indices used to take data + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Takes selected rows from dataframe +```nu +> let df = ([[a b]; [4 1] [5 2] [4 3]] | polars into-df); + let indices = ([0 2] | polars into-df); + $df | polars take $indices +╭───┬───┬───╮ +│ # │ a │ b │ +├───┼───┼───┤ +│ 0 │ 4 │ 1 │ +│ 1 │ 4 │ 3 │ +╰───┴───┴───╯ + +``` + +Takes selected rows from series +```nu +> let series = ([4 1 5 2 4 3] | polars into-df); + let indices = ([0 2] | polars into-df); + $series | polars take $indices +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 4 │ +│ 1 │ 5 │ +╰───┴───╯ + +``` diff --git a/commands/docs/polars_to-arrow.md b/commands/docs/polars_to-arrow.md new file mode 100644 index 0000000000..a8bdb2ddd6 --- /dev/null +++ b/commands/docs/polars_to-arrow.md @@ -0,0 +1,39 @@ +--- +title: polars to-arrow +categories: | + dataframe +version: 0.93.0 +dataframe: | + Saves dataframe to arrow file. +usage: | + Saves dataframe to arrow file. +feature: default +--- + + +# `polars to-arrow` for [dataframe](/commands/categories/dataframe.md) + +
Saves dataframe to arrow file.
+ +## Signature + +```> polars to-arrow {flags} (file)``` + +## Parameters + + - `file`: file path to save dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Saves dataframe to arrow file +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars to-arrow test.arrow + +``` diff --git a/commands/docs/polars_to-avro.md b/commands/docs/polars_to-avro.md new file mode 100644 index 0000000000..128a81f40f --- /dev/null +++ b/commands/docs/polars_to-avro.md @@ -0,0 +1,43 @@ +--- +title: polars to-avro +categories: | + dataframe +version: 0.93.0 +dataframe: | + Saves dataframe to avro file. +usage: | + Saves dataframe to avro file. +feature: default +--- + + +# `polars to-avro` for [dataframe](/commands/categories/dataframe.md) + +
Saves dataframe to avro file.
+ +## Signature + +```> polars to-avro {flags} (file)``` + +## Flags + + - `--compression, -c {string}`: use compression, supports deflate or snappy + +## Parameters + + - `file`: file path to save dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Saves dataframe to avro file +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars to-avro test.avro + +``` diff --git a/commands/docs/polars_to-csv.md b/commands/docs/polars_to-csv.md new file mode 100644 index 0000000000..b1f0bb8570 --- /dev/null +++ b/commands/docs/polars_to-csv.md @@ -0,0 +1,50 @@ +--- +title: polars to-csv +categories: | + dataframe +version: 0.93.0 +dataframe: | + Saves dataframe to CSV file. +usage: | + Saves dataframe to CSV file. +feature: default +--- + + +# `polars to-csv` for [dataframe](/commands/categories/dataframe.md) + +
Saves dataframe to CSV file.
+ +## Signature + +```> polars to-csv {flags} (file)``` + +## Flags + + - `--delimiter, -d {string}`: file delimiter character + - `--no-header, -`: Indicates if file doesn't have header + +## Parameters + + - `file`: file path to save dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Saves dataframe to CSV file +```nu +> [[a b]; [1 2] [3 4]] | dfr into-df | dfr to-csv test.csv + +``` + +Saves dataframe to CSV file using other delimiter +```nu +> [[a b]; [1 2] [3 4]] | dfr into-df | dfr to-csv test.csv --delimiter '|' + +``` diff --git a/commands/docs/polars_to-jsonl.md b/commands/docs/polars_to-jsonl.md new file mode 100644 index 0000000000..3008e761fb --- /dev/null +++ b/commands/docs/polars_to-jsonl.md @@ -0,0 +1,39 @@ +--- +title: polars to-jsonl +categories: | + dataframe +version: 0.93.0 +dataframe: | + Saves dataframe to a JSON lines file. +usage: | + Saves dataframe to a JSON lines file. +feature: default +--- + + +# `polars to-jsonl` for [dataframe](/commands/categories/dataframe.md) + +
Saves dataframe to a JSON lines file.
+ +## Signature + +```> polars to-jsonl {flags} (file)``` + +## Parameters + + - `file`: file path to save dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Saves dataframe to JSON lines file +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars to-jsonl test.jsonl + +``` diff --git a/commands/docs/polars_to-parquet.md b/commands/docs/polars_to-parquet.md new file mode 100644 index 0000000000..061d2e9552 --- /dev/null +++ b/commands/docs/polars_to-parquet.md @@ -0,0 +1,39 @@ +--- +title: polars to-parquet +categories: | + dataframe +version: 0.93.0 +dataframe: | + Saves dataframe to parquet file. +usage: | + Saves dataframe to parquet file. +feature: default +--- + + +# `polars to-parquet` for [dataframe](/commands/categories/dataframe.md) + +
Saves dataframe to parquet file.
+ +## Signature + +```> polars to-parquet {flags} (file)``` + +## Parameters + + - `file`: file path to save dataframe + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Saves dataframe to parquet file +```nu +> [[a b]; [1 2] [3 4]] | polars into-df | polars to-parquet test.parquet + +``` diff --git a/commands/docs/polars_unique.md b/commands/docs/polars_unique.md new file mode 100644 index 0000000000..35c6d43f19 --- /dev/null +++ b/commands/docs/polars_unique.md @@ -0,0 +1,79 @@ +--- +title: polars unique +categories: | + dataframe or lazyframe +version: 0.93.0 +dataframe_or_lazyframe: | + Returns unique values from a dataframe. +usage: | + Returns unique values from a dataframe. +feature: default +--- + + +# `polars unique` for [dataframe or lazyframe](/commands/categories/dataframe or lazyframe.md) + +
Returns unique values from a dataframe.
+ +## Signature + +```> polars unique {flags} ``` + +## Flags + + - `--subset, -s {any}`: Subset of column(s) to use to maintain rows (lazy df) + - `--last, -l`: Keeps last unique value. Default keeps first value (lazy df) + - `--maintain-order, -k`: Keep the same order as the original DataFrame (lazy df) + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Returns unique values from a series +```nu +> [2 2 2 2 2] | polars into-df | polars unique +╭───┬───╮ +│ # │ 0 │ +├───┼───┤ +│ 0 │ 2 │ +╰───┴───╯ + +``` + +Returns unique values in a subset of lazyframe columns +```nu +> [[a b c]; [1 2 1] [2 2 2] [3 2 1]] | polars into-lazy | polars unique --subset [b c] | polars collect +╭───┬───┬───┬───╮ +│ # │ a │ b │ c │ +├───┼───┼───┼───┤ +│ 0 │ 1 │ 2 │ 1 │ +│ 1 │ 2 │ 2 │ 2 │ +╰───┴───┴───┴───╯ + +``` + +Returns unique values in a subset of lazyframe columns +```nu +> [[a b c]; [1 2 1] [2 2 2] [3 2 1]] + | polars into-lazy + | polars unique --subset [b c] --last + | polars collect +╭───┬───┬───┬───╮ +│ # │ a │ b │ c │ +├───┼───┼───┼───┤ +│ 0 │ 2 │ 2 │ 2 │ +│ 1 │ 3 │ 2 │ 1 │ +╰───┴───┴───┴───╯ + +``` + +Creates a is unique expression from a column +```nu +> col a | unique + +``` diff --git a/commands/docs/polars_uppercase.md b/commands/docs/polars_uppercase.md new file mode 100644 index 0000000000..c3a5c3eb88 --- /dev/null +++ b/commands/docs/polars_uppercase.md @@ -0,0 +1,42 @@ +--- +title: polars uppercase +categories: | + dataframe +version: 0.93.0 +dataframe: | + Uppercase the strings in the column. +usage: | + Uppercase the strings in the column. +feature: default +--- + + +# `polars uppercase` for [dataframe](/commands/categories/dataframe.md) + +
Uppercase the strings in the column.
+ +## Signature + +```> polars uppercase {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Modifies strings to uppercase +```nu +> [Abc aBc abC] | polars into-df | polars uppercase +╭───┬─────╮ +│ # │ 0 │ +├───┼─────┤ +│ 0 │ ABC │ +│ 1 │ ABC │ +│ 2 │ ABC │ +╰───┴─────╯ + +``` diff --git a/commands/docs/polars_value-counts.md b/commands/docs/polars_value-counts.md new file mode 100644 index 0000000000..47a2244aba --- /dev/null +++ b/commands/docs/polars_value-counts.md @@ -0,0 +1,41 @@ +--- +title: polars value-counts +categories: | + dataframe +version: 0.93.0 +dataframe: | + Returns a dataframe with the counts for unique values in series. +usage: | + Returns a dataframe with the counts for unique values in series. +feature: default +--- + + +# `polars value-counts` for [dataframe](/commands/categories/dataframe.md) + +
Returns a dataframe with the counts for unique values in series.
+ +## Signature + +```> polars value-counts {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Calculates value counts +```nu +> [5 5 5 5 6 6] | polars into-df | polars value-counts +╭───┬───┬───────╮ +│ # │ 0 │ count │ +├───┼───┼───────┤ +│ 0 │ 5 │ 4 │ +│ 1 │ 6 │ 2 │ +╰───┴───┴───────╯ + +``` diff --git a/commands/docs/polars_var.md b/commands/docs/polars_var.md new file mode 100644 index 0000000000..35a2c4dea0 --- /dev/null +++ b/commands/docs/polars_var.md @@ -0,0 +1,55 @@ +--- +title: polars var +categories: | + expression +version: 0.93.0 +expression: | + Create a var expression for an aggregation. +usage: | + Create a var expression for an aggregation. +feature: default +--- + + +# `polars var` for [expression](/commands/categories/expression.md) + +
Create a var expression for an aggregation.
+ +## Signature + +```> polars var {flags} ``` + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Var value from columns in a dataframe or aggregates columns to their var value +```nu +> [[a b]; [6 2] [4 2] [2 2]] | polars into-df | polars var +╭───┬──────┬──────╮ +│ # │ a │ b │ +├───┼──────┼──────┤ +│ 0 │ 4.00 │ 0.00 │ +╰───┴──────┴──────╯ + +``` + +Var aggregation for a group-by +```nu +> [[a b]; [one 2] [one 2] [two 1] [two 1]] + | polars into-df + | polars group-by a + | polars agg (polars col b | polars var) +╭───┬─────┬──────╮ +│ # │ a │ b │ +├───┼─────┼──────┤ +│ 0 │ one │ 0.00 │ +│ 1 │ two │ 0.00 │ +╰───┴─────┴──────╯ + +``` diff --git a/commands/docs/polars_when.md b/commands/docs/polars_when.md new file mode 100644 index 0000000000..006c56a367 --- /dev/null +++ b/commands/docs/polars_when.md @@ -0,0 +1,67 @@ +--- +title: polars when +categories: | + expression +version: 0.93.0 +expression: | + Creates and modifies a when expression. +usage: | + Creates and modifies a when expression. +feature: default +--- + + +# `polars when` for [expression](/commands/categories/expression.md) + +
Creates and modifies a when expression.
+ +## Signature + +```> polars when {flags} (when expression) (then expression)``` + +## Parameters + + - `when expression`: when expression used for matching + - `then expression`: expression that will be applied when predicate is true + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Create a when conditions +```nu +> polars when ((polars col a) > 2) 4 + +``` + +Create a when conditions +```nu +> polars when ((polars col a) > 2) 4 | polars when ((polars col a) < 0) 6 + +``` + +Create a new column for the dataframe +```nu +> [[a b]; [6 2] [1 4] [4 1]] + | polars into-lazy + | polars with-column ( + polars when ((polars col a) > 2) 4 | polars otherwise 5 | polars as c + ) + | polars with-column ( + polars when ((polars col a) > 5) 10 | polars when ((polars col a) < 2) 6 | polars otherwise 0 | polars as d + ) + | polars collect +╭───┬───┬───┬───┬────╮ +│ # │ a │ b │ c │ d │ +├───┼───┼───┼───┼────┤ +│ 0 │ 6 │ 2 │ 4 │ 10 │ +│ 1 │ 1 │ 4 │ 5 │ 6 │ +│ 2 │ 4 │ 1 │ 4 │ 0 │ +╰───┴───┴───┴───┴────╯ + +``` diff --git a/commands/docs/polars_with-column.md b/commands/docs/polars_with-column.md new file mode 100644 index 0000000000..b2831efc4d --- /dev/null +++ b/commands/docs/polars_with-column.md @@ -0,0 +1,69 @@ +--- +title: polars with-column +categories: | + dataframe or lazyframe +version: 0.93.0 +dataframe_or_lazyframe: | + Adds a series to the dataframe. +usage: | + Adds a series to the dataframe. +feature: default +--- + + +# `polars with-column` for [dataframe or lazyframe](/commands/categories/dataframe or lazyframe.md) + +
Adds a series to the dataframe.
+ +## Signature + +```> polars with-column {flags} ...rest``` + +## Flags + + - `--name, -n {string}`: new column name + +## Parameters + + - `...rest`: series to be added or expressions used to define the new columns + + +## Input/output types: + +| input | output | +| ----- | ------ | +| any | any | + +## Examples + +Adds a series to the dataframe +```nu +> [[a b]; [1 2] [3 4]] + | polars into-df + | polars with-column ([5 6] | polars into-df) --name c +╭───┬───┬───┬───╮ +│ # │ a │ b │ c │ +├───┼───┼───┼───┤ +│ 0 │ 1 │ 2 │ 5 │ +│ 1 │ 3 │ 4 │ 6 │ +╰───┴───┴───┴───╯ + +``` + +Adds a series to the dataframe +```nu +> [[a b]; [1 2] [3 4]] + | polars into-lazy + | polars with-column [ + ((polars col a) * 2 | polars as "c") + ((polars col a) * 3 | polars as "d") + ] + | polars collect +╭───┬───┬───┬───┬───╮ +│ # │ a │ b │ c │ d │ +├───┼───┼───┼───┼───┤ +│ 0 │ 1 │ 2 │ 2 │ 3 │ +│ 1 │ 3 │ 4 │ 6 │ 9 │ +╰───┴───┴───┴───┴───╯ + +``` diff --git a/commands/docs/update_cells.md b/commands/docs/update_cells.md index ac617ad08c..4afa204183 100644 --- a/commands/docs/update_cells.md +++ b/commands/docs/update_cells.md @@ -48,11 +48,11 @@ Update the zero value cells to empty strings. $value } } -╭──────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────╮ -│ # │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 │ -├──────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼──────────────┤ -│ 0 │ 37 │ │ │ │ 37 │ │ │ -╰──────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────╯ +╭───┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────╮ +│ # │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 │ +├───┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤ +│ 0 │ 37 │ │ │ │ 37 │ │ │ +╰───┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────╯ ``` @@ -68,10 +68,10 @@ Update the zero value cells to empty strings in 2 last columns. $value } } -╭──────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬──────────────╮ -│ # │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 │ -├──────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼──────────────┤ -│ 0 │ 37 │ 0 │ 0 │ 0 │ 37 │ │ │ -╰──────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴───────────────┴──────────────╯ +╭───┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────╮ +│ # │ 2021-04-16 │ 2021-06-10 │ 2021-09-18 │ 2021-10-15 │ 2021-11-16 │ 2021-11-17 │ 2021-11-18 │ +├───┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤ +│ 0 │ 37 │ 0 │ 0 │ 0 │ 37 │ │ │ +╰───┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────╯ ```