-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecategorize.py
More file actions
23 lines (19 loc) · 854 Bytes
/
recategorize.py
File metadata and controls
23 lines (19 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'''Recategorize a categorical attribute.
Given a column in a defined schema table, creates its copy with values
recategorized using given translation rules.
'''
import rum
import rum.util
argparser = rum.defaultArgumentParser(__doc__)
argparser.add_argument('table', help='table containing the attribute')
argparser.add_argument('source', help='the attribute column to be recategorized')
argparser.add_argument('target', help='the column to create and put the result in')
argparser.add_argument('translation', help='a JSON file defining the translation')
argparser.add_argument('-o', '--overwrite', action='store_true',
help='overwrite existing table'
)
if __name__ == '__main__':
args = argparser.parse_args()
rum.util.Recategorizer.fromArgs(args).run(
args.table, args.source, args.target, args.translation, args.overwrite
)