Last active
March 30, 2016 18:55
-
-
Save csaid/55bb1c932546abfa8601555b0e7cf9a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from ggplot import diamonds | |
# 1) How do I easily create multiple summaries of multiple columns? | |
( | |
diamonds | |
.groupby('cut') | |
.agg(??) # Equivalent of summarize(mean_x = mean(x), var_xy = var(xy)) | |
) | |
# 2) How do I easily put multiple summaries back into the original data frame? | |
( | |
diamonds | |
.groupby('cut') | |
.?? # Equivalent of mutate(mean_x = mean(x), var_xy = var(xy))? | |
) | |
# 3) Not a huge deal, but creating new columns with .assign is more verbose than mutate() | |
( | |
diamonds | |
.assign(xy = lambda d: d.x + d.y, xz = lambda d: d.x + d.z) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment