Method: Polars::Expr#head

Defined in:
lib/polars/expr.rb

#head(n = 10) ⇒ Expr

Get the first n rows.

Examples:

df = Polars::DataFrame.new({"foo" => [1, 2, 3, 4, 5, 6, 7]})
df.head(3)
# =>
# shape: (3, 1)
# ┌─────┐
# │ foo │
# │ --- │
# │ i64 │
# ╞═════╡
# │ 1   │
# │ 2   │
# │ 3   │
# └─────┘

Parameters:

  • n (Integer) (defaults to: 10)

    Number of rows to return.

Returns:

[View source]

3107
3108
3109
# File 'lib/polars/expr.rb', line 3107

def head(n = 10)
  _from_rbexpr(_rbexpr.head(n))
end