[FR] Access newly created column within i,j,by, sort
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 164
- Avg merge
- 7h 31m
- Merged PRs (30d)
- 1
Description
- Access newly created column(s) within i, j, by, sort
`Example data:`
from datatable import dt, f, by
grades = [48, 99, 75, 80, 42, 80, 72, 68, 36, 78]
data = {'ID': ["x%d" % r for r in range(10)],
'Gender': ['F', 'M', 'F', 'M', 'F',
'M', 'F', 'M', 'M', 'M'],
'ExamYear': [2007, 2007, 2007, 2008, 2008,
2008, 2008, 2009, 2009, 2009],
'Class': ['algebra', 'stats', 'bio', 'algebra',
'algebra', 'stats', 'stats', 'algebra',
'bio', 'bio'],
'Participated': ['yes', 'yes', 'yes', 'yes', 'no',
'yes', 'yes', 'yes', 'yes', 'yes'],
'Passed': ['yes' if x > 50 else 'no' for x in grades],
'Employed': [True, True, True, False,
False, False, False, True, True, False],
'Grade': grades}
df = dt.Frame(data)
- Within j : This will allow for intermediate outputs, and make code cleaner and more reproducible, even giving the opportunity to reduce the number of nested aggregations or calculations. If possible, refer to the same column multiple times within j.
df[:,{'grade':dt.mean(f.Grade), 'new_avg':f.grade + 10},'Gender']
- Within by and sort : # sort the entire frame in descending order with `new_avg`, or group with it :
df[:,{'grade':dt.mean(f.Grade), 'new_avg':f.grade + 10},'Gender', dt.sort(-f.new_avg)]
Contributor guide
Assessment
This issue has not been assessed yet.