Skip to content

Commit

Permalink
update etl docs (move-coop#441)
Browse files Browse the repository at this point in the history
Co-authored-by: Shauna <[email protected]>
  • Loading branch information
ndelrossi7 and shaunagm authored Nov 9, 2020
1 parent 147adf4 commit 6fc083d
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions parsons/etl/etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,17 @@ def map_columns(self, column_map):
`Parsons Table` and also updates self
.. code-block:: python
tbl = [{'fn': 'Jane'},
{'lastname': 'Doe'},
{'dob': '1980-01-01'}]
column_map = {'first_name': ['fn', 'first', 'firstname'],
'last_name': ['ln', 'last', 'lastname'],
'date_of_birth': ['dob', 'birthday']}
tbl = [{fn: 'Jane'},
{lastname: 'Doe'},
{dob: '1980-01-01'}]
column_map = {first_name: ['fn', 'first', 'firstname'],
last_name: ['ln', 'last', 'lastname'],
date_of_birth: ['dob', 'birthday']}
tbl.map_columns(column_map)
print (tbl)
>> {{first_name: 'Jane', last_name: 'Doe', 'date_of_birth': '1908-01-01'}}
>> {{'first_name': 'Jane', 'last_name': 'Doe', 'date_of_birth': '1908-01-01'}}
"""

for c in self.columns:
Expand Down Expand Up @@ -274,19 +275,19 @@ def map_and_coalesce_columns(self, column_map):
.. code-block:: python
tbl = [{first: None},
{fn: 'Jane'},
{lastname: 'Doe'},
{dob: '1980-01-01'}]
tbl = [{'first': None},
{'fn': 'Jane'},
{'lastname': 'Doe'},
{'dob': '1980-01-01'}]
column_map = {first_name: ['fn', 'first', 'firstname'],
last_name: ['ln', 'last', 'lastname'],
date_of_birth: ['dob', 'birthday']}
column_map = {'first_name': ['fn', 'first', 'firstname'],
'last_name': ['ln', 'last', 'lastname'],
'date_of_birth': ['dob', 'birthday']}
tbl.map_and_coalesce_columns(column_map)
print (tbl)
>> {{first_name: 'Jane', last_name: 'Doe', 'date_of_birth': '1908-01-01'}}
>> {{'first_name': 'Jane', 'last_name': 'Doe', 'date_of_birth': '1908-01-01'}}
"""

for key, value in column_map.items():
Expand Down Expand Up @@ -674,12 +675,12 @@ def select_rows(self, *filters):
# Lambda Function
tbl2 = tbl.select_rows(lambda row: row.foo == 'a' and row.baz > 88.1)
tbl2
>>> {foo: 'a', 'bar': 2, 'baz': 88.1}
>>> {'foo': 'a', 'bar': 2, 'baz': 88.1}
# Expression String
tbl3 = tbl.select_rows("{foo} == 'a' and {baz} > 88.1")
tbl3
>>> {foo: 'a', 'bar': 2, 'baz': 88.1}
>>> {'foo': 'a', 'bar': 2, 'baz': 88.1}
`Args:`
\*filters: function or str
Expand Down

0 comments on commit 6fc083d

Please sign in to comment.