-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: swap pl$Series
and as_polars_series.default
#1015
Conversation
@@ -367,13 +369,15 @@ as_polars_series.POSIXlt = function(x, name = NULL, ...) { | |||
#' @rdname as_polars_series | |||
#' @export | |||
as_polars_series.data.frame = function(x, name = NULL, ...) { | |||
pl$DataFrame(unclass(x))$to_struct(name = name) | |||
as_polars_df(x)$to_struct(name = name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not directly related, but is a small refactoring to make object conversions more appropriate.
as_polars_series.vctrs_rcrd = function(x, name = NULL, ...) { | ||
pl$select(unclass(x))$to_struct(name = name) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
#' [as_polars_series()] is a generic function that converts an R object to | ||
#' [a polars Series][Series_class]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a list of R objects that can be converted to Series?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely needed... See #425.
The documentation for the arrow
package is helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can address #425 in full in another PR then
Related to #1012.
as_polars_series.default()
used to callpl$Series()
, but will be changed so thatpl$Series()
callsas_polars_series()
.This will ensure that every object is properly converted to a Series with
pl$Series()
.Python's
polars.Series.__init__()
internally converts various objects into a Series through a large number of conditional branches. This update is very similar to that.