-
Notifications
You must be signed in to change notification settings - Fork 11
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
Is it possible to have dplyr's group_by
+ mutate
behavior?
#201
Comments
In import tidypolars as tp
from tidypolars import col
path = (
"https://gist.githubusercontent.com/netj/8836201/" +
"raw/6f9306ad21398ea43cba4f7d537619d0e07d5ae3/iris.csv"
)
iris = tp.read_csv(path).rename(species = 'variety')
(
iris
.mutate(
result = col("petal.width") + tp.mean(col("petal.width")),
by = "species"
)
)
|
Lots of functions have the Basically - if a function can operate "by group" in the Hope this helps! If you have any other questions let me know. |
Excellent! Thanks a lot for the prompt and awesome response! |
Saw your blog post and I'm glad tidypolars is working out for you! Figured I would mention that tidypolars has a You can also use it to drop nulls from specific columns if you want. # drop nulls from all columns
df.drop_null()
# drop nulls from "x" and "y"
df.drop_null('x', 'y') |
Awesome! I'll update the post! |
I am reopening this issue. I added a pull request that implements group_by + mutate as a proof of concept. Other functions applied to grouped Tibble can be implemented following the example. |
First of all, I really like this package and I've started to use it a lot in my work. As a Pythonista whose first language is R, I really enjoy
tidypolars
.In R, we can do something like the following
Since we have a
group_by(Species)
call,dplyr
will subtract the mean that corresponds to each group in themutate()
operation (not the mean across all observations from all species).As far as I understand, this is still not possible with
tidypolars
since we don't have agroup_by
function that behaves in a similar way to the one indplyr
. So my questions aretidypolars
now?Again, thanks for the fantastic library!
The text was updated successfully, but these errors were encountered: