Skip to content

Commit

Permalink
Update conversions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
javidy authored and juarezr committed Mar 23, 2021
1 parent e9b3e87 commit ff6e7a3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions petl/transform/conversions.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,21 @@ def convert(table, *args, **kwargs):
+-----+-------+--------------------+
| 'C' | '1.2' | 67.2 |
+-----+-------+--------------------+
>>> # conversion can use a custom function
>>> def my_func(val, row):
... return float(row.bar) + row.baz
...
>>> table13 = etl.convert(table1, 'foo', my_func, pass_row=True)
>>> table13
+------+-------+-----+
| foo | bar | baz |
+======+=======+=====+
| 14.4 | '2.4' | 12 |
+------+-------+-----+
| 39.7 | '5.7' | 34 |
+------+-------+-----+
| 57.2 | '1.2' | 56 |
+------+-------+-----+
Note that either field names or indexes can be given.
Expand Down

0 comments on commit ff6e7a3

Please sign in to comment.