Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

polars for dataframe

Operate with data in a dataframe format.

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:

inputoutput
nothingstring

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:

namedescriptiontype
polars aggPerforms a series of aggregations from a group-by.plugin
polars agg-groupsCreates an agg_groups expression.plugin
polars all-falseReturns true if all values are false.plugin
polars all-trueReturns true if all values are true.plugin
polars appendAppends a new dataframe.plugin
polars arg-maxReturn index for max value in series.plugin
polars arg-minReturn index for min value in series.plugin
polars arg-sortReturns indexes for a sorted series.plugin
polars arg-trueReturns indexes where values are true.plugin
polars arg-uniqueReturns indexes for unique values.plugin
polars arg-whereCreates an expression that returns the arguments where expression is true.plugin
polars asCreates an alias expression.plugin
polars as-dateConverts string to date.plugin
polars as-datetimeConverts string to datetime.plugin
polars cacheCaches operations in a new LazyFrame.plugin
polars castCast a column to a different dtype.plugin
polars colCreates a named column expression.plugin
polars collectCollect lazy dataframe into eager dataframe.plugin
polars columnsShow dataframe columns.plugin
polars concatConcatenate two or more dataframes.plugin
polars concat-strCreates a concat string expression.plugin
polars containsChecks if a pattern is contained in a string.plugin
polars convert-time-zoneConvert datetime to target timezone.plugin
polars countReturns the number of non-null values in the column.plugin
polars count-nullCounts null values.plugin
polars cumulativeCumulative calculation for a column or series.plugin
polars cutBin continuous values into discrete categories for a series.plugin
polars datepartCreates an expression for capturing the specified datepart in a column.plugin
polars decimalConverts a string column into a decimal columnplugin
polars dropCreates a new dataframe by dropping the selected columns.plugin
polars drop-duplicatesDrops duplicate values in dataframe.plugin
polars drop-nullsDrops null values in dataframe.plugin
polars dummiesCreates a new dataframe with dummy variables.plugin
polars explodeExplodes a dataframe or creates a explode expression.plugin
polars expr-notCreates a not expression.plugin
polars fetchCollects the lazyframe to the selected rows.plugin
polars fill-nanReplaces NaN values with the given expression.plugin
polars fill-nullReplaces NULL values with the given expression.plugin
polars filterFilter dataframe based in expression.plugin
polars filter-withFilters dataframe using a mask or expression as reference.plugin
polars firstShow only the first number of rows or create a first expressionplugin
polars flattenAn alias for polars explode.plugin
polars getCreates dataframe with the selected columns.plugin
polars get-dayGets day from date.plugin
polars get-hourGets hour from datetime.plugin
polars get-minuteGets minute from date.plugin
polars get-monthGets month from date.plugin
polars get-nanosecondGets nanosecond from date.plugin
polars get-ordinalGets ordinal from date.plugin
polars get-secondGets second from date.plugin
polars get-weekGets week from date.plugin
polars get-weekdayGets weekday from date.plugin
polars get-yearGets year from date.plugin
polars group-byCreates a group-by object that can be used for other aggregations.plugin
polars horizontalHorizontal calculation across multiple columns.plugin
polars implodeAggregates values into a list.plugin
polars integerConverts a string column into a integer columnplugin
polars into-dfConverts a list, table or record into a dataframe.plugin
polars into-dtypeConvert a string to a specific datatype.plugin
polars into-lazyConverts a dataframe into a lazy dataframe.plugin
polars into-nuConverts a dataframe or an expression into nushell value for access and exploration.plugin
polars into-reprDisplay a dataframe in its repr format.plugin
polars into-schemaConvert a value to a polars schema objectplugin
polars is-duplicatedCreates mask indicating duplicated values.plugin
polars is-inCreates an is-in expression or checks to see if the elements are contained in the right seriesplugin
polars is-not-nullCreates mask where value is not null.plugin
polars is-nullCreates mask where value is null.plugin
polars is-uniqueCreates mask indicating unique values.plugin
polars joinJoins a lazy frame with other lazy frame.plugin
polars join-whereJoins a lazy frame with other lazy frame based on conditions.plugin
polars lastCreates new dataframe with tail rows or creates a last expression.plugin
polars lenReturn the number of rows in the context. This is similar to COUNT(*) in SQL.plugin
polars list-containsChecks if an element is contained in a list.plugin
polars litCreates a literal expression.plugin
polars lowercaseLowercase the strings in the column.plugin
polars mathCollection of math functions to be applied on one or more column expressionsplugin
polars maxCreates a max expression or aggregates columns to their max value.plugin
polars meanCreates a mean expression for an aggregation or aggregates columns to their mean value.plugin
polars medianMedian value from columns in a dataframe or creates expression for an aggregationplugin
polars minCreates a min expression or aggregates columns to their min value.plugin
polars n-uniqueCounts unique values.plugin
polars notInverts boolean mask.plugin
polars openOpens 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 otherwiseCompletes a when expression.plugin
polars overCompute expressions over a window group defined by partition expressions.plugin
polars pivotPivot a DataFrame from long to wide format.plugin
polars profileProfile a lazy dataframe.plugin
polars qcutBin continuous values into discrete categories based on their quantiles for a series.plugin
polars quantileAggregates the columns to the selected quantile.plugin
polars queryQuery dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause.plugin
polars renameRename a dataframe column.plugin
polars replaceCreate an expression that replaces old values with new valuesplugin
polars replace-time-zoneReplace the timezone information in a datetime column.plugin
polars reverseReverses the LazyFrameplugin
polars rollingRolling calculation for a series.plugin
polars sampleCreate sample dataframe.plugin
polars saveSaves 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 schemaShow schema for a dataframe.plugin
polars selectSelects columns from lazyframe.plugin
polars setSets value where given mask is true.plugin
polars set-with-idxSets value in the given index.plugin
polars shapeShows column and row size for a dataframe.plugin
polars shiftShifts the values by a given period.plugin
polars sliceCreates new dataframe from a slice of rows.plugin
polars sort-bySorts a lazy dataframe based on expression(s).plugin
polars stdCreates a std expression for an aggregation of std value from columns in a dataframe.plugin
polars store-getGets a Dataframe or other object from the plugin cache.plugin
polars store-lsLists stored polars objects.plugin
polars store-rmRemoves a stored Dataframe or other object from the plugin cache.plugin
polars str-joinConcatenates strings within a column or dataframesplugin
polars str-lengthsGet lengths of all strings.plugin
polars str-replaceReplace the leftmost (sub)string by a regex pattern.plugin
polars str-replace-allReplace all (sub)strings by a regex pattern.plugin
polars str-sliceSlices the string from the start position until the selected length.plugin
polars str-splitSplit the string by a substring. The resulting dtype is list<str>.plugin
polars str-strip-charsStrips specified characters from strings in a columnplugin
polars strftimeFormats date based on string rule.plugin
polars struct-json-encodeConvert this struct to a string column with json values.plugin
polars sumCreates a sum expression for an aggregation or aggregates columns to their sum value.plugin
polars summaryFor a dataframe, produces descriptive statistics (summary statistics) for its numeric columns.plugin
polars takeCreates new dataframe using the given indices.plugin
polars truncateDivide the date/datetime range into buckets.plugin
polars uniqueReturns unique values from a dataframe.plugin
polars unnestDecompose 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 unpivotUnpivot a DataFrame from wide to long format.plugin
polars uppercaseUppercase the strings in the column.plugin
polars value-countsReturns a dataframe with the counts for unique values in series.plugin
polars varCreate a var expression for an aggregation.plugin
polars whenCreates and modifies a when expression.plugin
polars with-columnAdds a series to the dataframe.plugin