polars
for dataframe
This command requires a plugin
The polars
command resides in the polars
plugin. To use this command, you must install and register nu_plugin_polars
. See the Plugins chapter in the book for more information.
Signature
> polars {flags}
Input/output types:
input | output |
---|---|
nothing | string |
Notes
You must use one of the subcommands below. Using this command as-is will only produce this help message.
The following are the main datatypes (wrapped from Polars) that are used by these subcommands:
Lazy and Strict dataframes (called NuLazyFrame
and NuDataFrame
in error messages) are the main data structure.
Expressions, representing various column operations (called NuExpression
), are passed to many commands such as polars filter
or polars with-column
. Most nushell operators are supported in these expressions, importantly arithmetic, comparison and boolean logical.
Groupbys (NuLazyGroupBy
), the output of a polars group-by
, represent a grouped dataframe and are typically piped to the polars agg
command with some column expressions for aggregation which then returns a dataframe.
Subcommands:
name | description | type |
---|---|---|
polars agg | Performs a series of aggregations from a group-by. | plugin |
polars agg-groups | Creates an agg_groups expression. | plugin |
polars all-false | Returns true if all values are false. | plugin |
polars all-true | Returns true if all values are true. | plugin |
polars append | Appends a new dataframe. | plugin |
polars arg-max | Return index for max value in series. | plugin |
polars arg-min | Return index for min value in series. | plugin |
polars arg-sort | Returns indexes for a sorted series. | plugin |
polars arg-true | Returns indexes where values are true. | plugin |
polars arg-unique | Returns indexes for unique values. | plugin |
polars arg-where | Creates an expression that returns the arguments where expression is true. | plugin |
polars as | Creates an alias expression. | plugin |
polars as-date | Converts string to date. | plugin |
polars as-datetime | Converts string to datetime. | plugin |
polars cache | Caches operations in a new LazyFrame. | plugin |
polars cast | Cast a column to a different dtype. | plugin |
polars col | Creates a named column expression. | plugin |
polars collect | Collect lazy dataframe into eager dataframe. | plugin |
polars columns | Show dataframe columns. | plugin |
polars concat | Concatenate two or more dataframes. | plugin |
polars concat-str | Creates a concat string expression. | plugin |
polars contains | Checks if a pattern is contained in a string. | plugin |
polars count | Returns the number of non-null values in the column. | plugin |
polars count-null | Counts null values. | plugin |
polars cumulative | Cumulative calculation for a column or series. | plugin |
polars datepart | Creates an expression for capturing the specified datepart in a column. | plugin |
polars decimal | Converts a string column into a decimal column | plugin |
polars drop | Creates a new dataframe by dropping the selected columns. | plugin |
polars drop-duplicates | Drops duplicate values in dataframe. | plugin |
polars drop-nulls | Drops null values in dataframe. | plugin |
polars dummies | Creates a new dataframe with dummy variables. | plugin |
polars explode | Explodes a dataframe or creates a explode expression. | plugin |
polars expr-not | Creates a not expression. | plugin |
polars fetch | Collects the lazyframe to the selected rows. | plugin |
polars fill-nan | Replaces NaN values with the given expression. | plugin |
polars fill-null | Replaces NULL values with the given expression. | plugin |
polars filter | Filter dataframe based in expression. | plugin |
polars filter-with | Filters dataframe using a mask or expression as reference. | plugin |
polars first | Show only the first number of rows or create a first expression | plugin |
polars flatten | An alias for polars explode. | plugin |
polars get | Creates dataframe with the selected columns. | plugin |
polars get-day | Gets day from date. | plugin |
polars get-hour | Gets hour from date. | plugin |
polars get-minute | Gets minute from date. | plugin |
polars get-month | Gets month from date. | plugin |
polars get-nanosecond | Gets nanosecond from date. | plugin |
polars get-ordinal | Gets ordinal from date. | plugin |
polars get-second | Gets second from date. | plugin |
polars get-week | Gets week from date. | plugin |
polars get-weekday | Gets weekday from date. | plugin |
polars get-year | Gets year from date. | plugin |
polars group-by | Creates a group-by object that can be used for other aggregations. | plugin |
polars implode | Aggregates values into a list. | plugin |
polars integer | Converts a string column into a integer column | plugin |
polars into-df | Converts a list, table or record into a dataframe. | plugin |
polars into-lazy | Converts a dataframe into a lazy dataframe. | plugin |
polars into-nu | Converts a dataframe or an expression into nushell value for access and exploration. | plugin |
polars into-repr | Display a dataframe in its repr format. | plugin |
polars is-duplicated | Creates mask indicating duplicated values. | plugin |
polars is-in | Creates an is-in expression or checks to see if the elements are contained in the right series | plugin |
polars is-not-null | Creates mask where value is not null. | plugin |
polars is-null | Creates mask where value is null. | plugin |
polars is-unique | Creates mask indicating unique values. | plugin |
polars join | Joins a lazy frame with other lazy frame. | plugin |
polars last | Creates new dataframe with tail rows or creates a last expression. | plugin |
polars len | Return the number of rows in the context. This is similar to COUNT(*) in SQL. | plugin |
polars list-contains | Checks if an element is contained in a list. | plugin |
polars lit | Creates a literal expression. | plugin |
polars lowercase | Lowercase the strings in the column. | plugin |
polars max | Creates a max expression or aggregates columns to their max value. | plugin |
polars mean | Creates a mean expression for an aggregation or aggregates columns to their mean value. | plugin |
polars median | Median value from columns in a dataframe or creates expression for an aggregation | plugin |
polars min | Creates a min expression or aggregates columns to their min value. | plugin |
polars n-unique | Counts unique values. | plugin |
polars not | Inverts boolean mask. | plugin |
polars open | Opens CSV, JSON, NDJSON/JSON lines, arrow, avro, or parquet file to create dataframe. A lazy dataframe will be created by default, if supported. | plugin |
polars otherwise | Completes a when expression. | plugin |
polars pivot | Pivot a DataFrame from wide to long format. | plugin |
polars profile | Profile a lazy dataframe. | plugin |
polars quantile | Aggregates the columns to the selected quantile. | plugin |
polars query | Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause. | plugin |
polars rename | Rename a dataframe column. | plugin |
polars replace | Replace the leftmost (sub)string by a regex pattern. | plugin |
polars replace-all | Replace all (sub)strings by a regex pattern. | plugin |
polars reverse | Reverses the LazyFrame | plugin |
polars rolling | Rolling calculation for a series. | plugin |
polars sample | Create sample dataframe. | plugin |
polars save | Saves a dataframe to disk. For lazy dataframes a sink operation will be used if the file type supports it (parquet, ipc/arrow, csv, and ndjson). | plugin |
polars schema | Show schema for a dataframe. | plugin |
polars select | Selects columns from lazyframe. | plugin |
polars set | Sets value where given mask is true. | plugin |
polars set-with-idx | Sets value in the given index. | plugin |
polars shape | Shows column and row size for a dataframe. | plugin |
polars shift | Shifts the values by a given period. | plugin |
polars slice | Creates new dataframe from a slice of rows. | plugin |
polars sort-by | Sorts a lazy dataframe based on expression(s). | plugin |
polars std | Creates a std expression for an aggregation of std value from columns in a dataframe. | plugin |
polars store-get | Gets a Dataframe or other object from the plugin cache. | plugin |
polars store-ls | Lists stored polars objects. | plugin |
polars store-rm | Removes a stored Dataframe or other object from the plugin cache. | plugin |
polars str-join | Concatenates strings within a column or dataframes | plugin |
polars str-lengths | Get lengths of all strings. | plugin |
polars str-slice | Slices the string from the start position until the selected length. | plugin |
polars str-split | Split the string by a substring. The resulting dtype is list<str>. | plugin |
polars str-strip-chars | Strips specified characters from strings in a column | plugin |
polars strftime | Formats date based on string rule. | plugin |
polars sum | Creates a sum expression for an aggregation or aggregates columns to their sum value. | plugin |
polars summary | For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns. | plugin |
polars take | Creates new dataframe using the given indices. | plugin |
polars unique | Returns unique values from a dataframe. | plugin |
polars unnest | Decompose struct columns into separate columns for each of their fields. The new columns will be inserted into the dataframe at the location of the struct column. | plugin |
polars unpivot | Unpivot a DataFrame from wide to long format. | plugin |
polars uppercase | Uppercase the strings in the column. | plugin |
polars value-counts | Returns a dataframe with the counts for unique values in series. | plugin |
polars var | Create a var expression for an aggregation. | plugin |
polars when | Creates and modifies a when expression. | plugin |
polars with-column | Adds a series to the dataframe. | plugin |