pplyr
pplyr lets you use dplyrs grammar of data manipulation from within python without any code changes.
Install
pip install pplyr
How to use
from pplyr.core import pplyr
import pandas as pd
df = pd.read_csv("iris.csv", index_col=0)
dplyr = """
df = df %>% group_by(Species) %>% summarize_all(list(mean = mean)) %>% select(-X_mean)
"""
pplyr(df, dplyr)
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
Species | Sepal.Length_mean | Sepal.Width_mean | Petal.Length_mean | Petal.Width_mean | |
---|---|---|---|---|---|
1 | setosa | 5.006 | 3.428 | 1.462 | 0.246 |
2 | versicolor | 5.936 | 2.770 | 4.260 | 1.326 |
3 | virginica | 6.588 | 2.974 | 5.552 | 2.026 |