Create an empty or n
-row null-filled copy of the frame
Description
Returns a n
-row null-filled frame with an identical schema.
n
can be greater than the current number of rows in the
frame.
Usage
<DataFrame>$clear(n = 0)
Arguments
n
|
Number of (null-filled) rows to return in the cleared frame. |
Value
A polars DataFrame
Examples
library("polars")
df <- pl$DataFrame(
a = c(NA, 2, 3, 4),
b = c(0.5, NA, 2.5, 13),
c = c(TRUE, TRUE, FALSE, NA)
)
df$clear()
#> shape: (0, 3)
#> ┌─────┬─────┬──────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ f64 ┆ bool │
#> ╞═════╪═════╪══════╡
#> └─────┴─────┴──────┘
#> shape: (2, 3)
#> ┌──────┬──────┬──────┐
#> │ a ┆ b ┆ c │
#> │ --- ┆ --- ┆ --- │
#> │ f64 ┆ f64 ┆ bool │
#> ╞══════╪══════╪══════╡
#> │ null ┆ null ┆ null │
#> │ null ┆ null ┆ null │
#> └──────┴──────┴──────┘