For development:
git clone https://github.com/AnswerDotAI/basedtab.git
pip install -e .Install latest from the GitHub repository:
$ pip install git+https://github.com/AnswerDotAI/basedtab.gitor from conda
$ conda install -c AnswerDotAI basedtabor from pypi
$ pip install basedtabfrom basedtab.core import *
from nbdev.config import get_config
data_path = str(get_config().config_path/'data/toy.csv')
bf = BFrame.read_csv(data_path)
bf.head(3).df
<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>
| Number | City | Gender | Age | Income | Illness | |
|---|---|---|---|---|---|---|
| 0 | 1 | Dallas | Male | 41 | 40367.0 | No |
| 1 | 2 | Dallas | Male | 54 | 45084.0 | No |
| 2 | 3 | Dallas | Male | 42 | 52483.0 | No |
from basedpl import add, tally, square
MEAN = add.reduce_first / tally
bf.groupby("City", "Income", mean=MEAN).df.astype(int)
<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>
| Income | ||
|---|---|---|
| 0 | mean | 45252 |
| 1 | mean | 96857 |
| 2 | mean | 95264 |
| 3 | mean | 135078 |
| 4 | mean | 91554 |
| 5 | mean | 70991 |
| 6 | mean | 100756 |
| 7 | mean | 90277 |
RMSE = MEAN.under(square)
bf.head(100).groupby("Gender", ["Age", "Income"], mean=MEAN, rmse=RMSE)┌→───────────────────────────┐
↓0⌷ │
↓ Age Income│
│mean 44.57407407 48301.42593│
│rmse 45.66970793 49632.10639│
│ │
│1⌷ │
│ Age Income│
│mean 45.30434783 39739.36957│
│rmse 46.73468128 40738.65853│
└~───────────────────────────┘
bf["Income"].hist()