Skip to content

Commit

Permalink
move merge funcs inside
Browse files Browse the repository at this point in the history
  • Loading branch information
Tagar committed Feb 18, 2018
1 parent c661d71 commit 24cbb5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions abalon/spark/pivoter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
###########################################################################################################


def simple_merge_two_dicts (x, y, agg_op):
x.update(y) # modifies x with y's keys and values & returns None
return x

def BasicSparkPivoter (df, all_vars=None):

'''
Expand All @@ -73,14 +69,12 @@ def BasicSparkPivoter (df, all_vars=None):
:return: resulting dataframe
'''

return pivot_df(df, simple_merge_two_dicts, all_vars)
def simple_merge_two_dicts(x, y, agg_op):
x.update(y) # modifies x with y's keys and values & returns None
return x

return pivot_df(df, simple_merge_two_dicts, all_vars)

def agg_merge_two_dicts(x, y, agg_op):
return {k: agg_op(x.get(k, 0.0),
y.get(k, 0.0))
for k in set(x).union(y)
}

def AggSparkPivoter (df, all_vars=None, agg_op=operator.add):

Expand All @@ -94,6 +88,12 @@ def AggSparkPivoter (df, all_vars=None, agg_op=operator.add):
:return: resulting dataframe
'''

def agg_merge_two_dicts(x, y, agg_op):
return {k: agg_op(x.get(k, 0.0),
y.get(k, 0.0))
for k in set(x).union(y)
}

return pivot_df(df, agg_merge_two_dicts, all_vars, agg_op)


Expand Down
2 changes: 1 addition & 1 deletion abalon/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version = '2.2.0'
version = '2.2.1'


0 comments on commit 24cbb5c

Please sign in to comment.