Skip to content

Commit 2279e55

Browse files
committed
fix: remove unnecessary warnings in select module
1 parent b9a2fe4 commit 2279e55

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

book/content/data_manipulation/_select_columns.qmd

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,9 @@ iris_dt[1:3,.(Petal.Length,Petal.Width)]
5353
```
5454
:::
5555

56-
**Keep in mind that when:**
57-
- Square brackets are used:
58-
- **Selecting only one column** from a `DataFrame`, the output is a `Series`;
59-
- Whereas **if there is more than one column selected**, the output is a `DataFrame`.
60-
- `select()` method is used:
61-
- **The output is always a `DataFrame`** rather than a `Series` even if one column is selected.
62-
=> If you need a `Series` you can use the `to_series()` method. See [here](#get-series-from-dataFrame).
63-
64-
```{r}
65-
#| label: select-output-polars
66-
67-
inherits(as_polars_df(iris)[,"Petal.Length"],"Series")
68-
inherits(as_polars_df(iris)[,"Petal.Length"],"DataFrame")
69-
inherits(as_polars_df(iris)[,c("Petal.Length","Petal.Width")],"DataFrame")
70-
inherits(as_polars_df(iris)[,c("Petal.Length","Petal.Width")],"Series")
71-
```
72-
73-
With Polars if you want to obtain a result in an R data.frame, you can simply use the function `as.data.frame()`. See [here](#from-seriesdataframes-to-vectordata.frames) for examples.
74-
75-
::: {.callout-tip}
76-
Beyond the minor differences discussed above, there are **two major reasons why you should use the `select()` method over the syntax with square brackets:**
56+
There are **two major reasons why you should use the `select()` method over the syntax with square brackets:**
7757
- When you select and transform multiple columns with `select()` method, Polars will run these selections **in parallel**;
7858
- Expressions used in `select()` method can be optimised in [lazy mode](#introduction-to-lazy-mode) by the query optimizer.
79-
:::
8059

8160
### Selecting by data type
8261

0 commit comments

Comments
 (0)