Skip to content

Comments

working apply functionality#28

Merged
mikeAdamss merged 2 commits intogss_speedupfrom
issue-27/apply-keyword-in-constructor
Apr 29, 2021
Merged

working apply functionality#28
mikeAdamss merged 2 commits intogss_speedupfrom
issue-27/apply-keyword-in-constructor

Conversation

@mikeAdamss
Copy link

@mikeAdamss mikeAdamss commented Apr 17, 2021

allow passing of functions into a databaker dimension constructor to allow any required override/modification of dimension headers before they are pivoted.

HDim(cells, "My Dim", CLOSEST, ABOVE, apply=my_function)

or even

HDim(cells, "My Dim", CLOSEST, ABOVE, apply=lambda x: x.strip())

So basically a databaker parallel of the pandas apply() method. Is uber performant (changing a single string beats changing a subset of a series hands down) and should lead to cleaner code with much less of a reliance on post processing.

also test feature for same plus corrected a given to a then for test readability in an unconnected scenario (spotted in passing).

@mikeAdamss mikeAdamss linked an issue Apr 17, 2021 that may be closed by this pull request
@mikeAdamss
Copy link
Author

need to extend this to optionally take a tuple of functions, eg:

HDim(cells, "My Dim", CLOSEST, ABOVE, apply=(my_function, lambda x: (int(x)))

as there's bound to be times we want to make more than one intervention at the HDim constructor level.

@mikeAdamss mikeAdamss force-pushed the issue-27/apply-keyword-in-constructor branch from 2e4054d to 206023a Compare April 28, 2021 13:41
@mikeAdamss mikeAdamss merged commit 80408cb into gss_speedup Apr 29, 2021
@mikeAdamss mikeAdamss deleted the issue-27/apply-keyword-in-constructor branch April 29, 2021 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pass function to dimension constructor

1 participant