-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.2.dev5] Template for column from expression #105
Conversation
|
||
""" | ||
if self.column_name is None: | ||
raise ValueError("Please provide a column name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line uses double quotes but there are single quotes in other parts of the file. In the future we can use pylint to ensure uniform code style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use double quotes for natural-language messages and single quotes for strings that are more like data, i think. Not sure if this is a standard or just a habit i picked up, though! We can see what pylint wants.
raise ValueError("Please provide a column name") | ||
|
||
if self.table is None: | ||
raise ValueError("Please provide a table") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
raise ValueError("Please provide a table") | ||
|
||
if self.expression is None: | ||
raise ValueError("Please provide an expression") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
This PR adds a template to register a column of derived data with Orca, based on an expression. This is the first use case from issue #98.
New template
urbansim_templates.data.ColumnFromExpression()
The expression is passed to
df.eval()
and can refer to other columns in the same table, including stand-alone columns that have not yet been evaluated. It supports arithmetic and math functions including sqrt, abs, log, exp, log1p, and expm1.More info about the expression parsing:
Template-specific parameters:
column_name
table
expression
data_type
(optional)missing_values
(optional)cache
(optional)cache_scope
(optional)Versioning
To do before merging
run()
method