You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a computed field that is computed using a Python callable
This is very useful and can be reused. It might make sense to merge with dataflows.add_computed_field.
h/t @shevron
def add_computed_field_callable(name, type, callback, **options):
def func(package):
# Alter the schema to add a field
for resource in package.pkg.descriptor['resources']:
resource['schema']['fields'].append(dict(name=name, type=type, **options))
yield package.pkg
def value_setter(rows):
for row in rows:
row[name] = callback(row)
yield row
for resource in package:
yield value_setter(resource)
return func
The text was updated successfully, but these errors were encountered:
Add a computed field that is computed using a Python callable
This is very useful and can be reused. It might make sense to merge with
dataflows.add_computed_field
.h/t @shevron
The text was updated successfully, but these errors were encountered: