pola-rs / r-polars

Bring polars to R
https://pola-rs.github.io/r-polars/
Other
415 stars 36 forks source link

refactor: remove more useless dispatched methods from Series #1008

Closed eitsupi closed 2 months ago

eitsupi commented 2 months ago

I listed the RPolarsSeries-specific methods that are not present in the Series of Python Polars as shown below, and checked to see if any extra methods were dispatched from Expr.

In Python:

import polars as pl

l = dir(pl.Series)

with open("list.txt", "w") as f:
    for item in l:
        f.write(f"{item}\n")

Then, in R:

> methods_py <- readr::read_lines("list.txt")
> methods_r <- ls(polars::.pr$env$RPolarsSeries)
> setdiff(methods_r, methods_py)
 [1] "add"             "and"             "approx_n_unique" "backward_fill"   "compare"        
 [6] "div"             "exclude"         "first"           "flatten"         "floor_div"      
[11] "forward_fill"    "gt_eq"           "inspect"         "last"            "lt_eq"          
[16] "map_batches"     "mod"             "mul"             "neq"             "neq_missing"    
[21] "not"             "or"              "print"           "rep"             "rep_extend"     
[26] "repeat_by"       "sort_by"         "sub"             "to_lit"          "to_r"           
[31] "to_struct"       "to_vector"       "xor"

As a result, several methods were determined to be unnecessary and will be removed. (There are others that are only available in R, but Python does not dispatch Expr methods outside of the subnamespace, so it appears that not all Expr methods are available on the Series.)

See #1006 for rep_extend.