partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
error_parsing
Print any parsing error and exit with status -1
mongotail/err.py
def error_parsing(msg="unknown options"): """ Print any parsing error and exit with status -1 """ sys.stderr.write("Error parsing command line: %s\ntry 'mongotail --help' for more information\n" % msg) sys.stderr.flush() exit(EINVAL)
def error_parsing(msg="unknown options"): """ Print any parsing error and exit with status -1 """ sys.stderr.write("Error parsing command line: %s\ntry 'mongotail --help' for more information\n" % msg) sys.stderr.flush() exit(EINVAL)
[ "Print", "any", "parsing", "error", "and", "exit", "with", "status", "-", "1" ]
mrsarm/mongotail
python
https://github.com/mrsarm/mongotail/blob/82ba74e32eff92faa320833a8d19c58555f9cd49/mongotail/err.py#L42-L48
[ "def", "error_parsing", "(", "msg", "=", "\"unknown options\"", ")", ":", "sys", ".", "stderr", ".", "write", "(", "\"Error parsing command line: %s\\ntry 'mongotail --help' for more information\\n\"", "%", "msg", ")", "sys", ".", "stderr", ".", "flush", "(", ")", "...
82ba74e32eff92faa320833a8d19c58555f9cd49
test
Menu.get_product_by_name
Gets a Item from the Menu by name. Note that the name is not case-sensitive but must be spelt correctly. :param string name: The name of the item. :raises StopIteration: Raises exception if no item is found. :return: An item object matching the search. :rtype: Item
dominos/models.py
def get_product_by_name(self, name): ''' Gets a Item from the Menu by name. Note that the name is not case-sensitive but must be spelt correctly. :param string name: The name of the item. :raises StopIteration: Raises exception if no item is found. :return: An item objec...
def get_product_by_name(self, name): ''' Gets a Item from the Menu by name. Note that the name is not case-sensitive but must be spelt correctly. :param string name: The name of the item. :raises StopIteration: Raises exception if no item is found. :return: An item objec...
[ "Gets", "a", "Item", "from", "the", "Menu", "by", "name", ".", "Note", "that", "the", "name", "is", "not", "case", "-", "sensitive", "but", "must", "be", "spelt", "correctly", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/models.py#L59-L69
[ "def", "get_product_by_name", "(", "self", ",", "name", ")", ":", "return", "next", "(", "i", "for", "i", "in", "self", ".", "items", "if", "i", ".", "name", ".", "lower", "(", ")", "==", "name", ".", "lower", "(", ")", ")" ]
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.new_session
Clear out the current session on the remote and setup a new one. :return: A response from having expired the current session. :rtype: requests.Response
dominos/api.py
def new_session(self, session): ''' Clear out the current session on the remote and setup a new one. :return: A response from having expired the current session. :rtype: requests.Response ''' response = self.__get('/Home/SessionExpire') self.session = update_sess...
def new_session(self, session): ''' Clear out the current session on the remote and setup a new one. :return: A response from having expired the current session. :rtype: requests.Response ''' response = self.__get('/Home/SessionExpire') self.session = update_sess...
[ "Clear", "out", "the", "current", "session", "on", "the", "remote", "and", "setup", "a", "new", "one", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L31-L41
[ "def", "new_session", "(", "self", ",", "session", ")", ":", "response", "=", "self", ".", "__get", "(", "'/Home/SessionExpire'", ")", "self", ".", "session", "=", "update_session_headers", "(", "session", ")", "return", "response" ]
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.reset_store
Clears out the current store and gets a cookie. Set the cross site request forgery token for each subsequent request. :return: A response having cleared the current store. :rtype: requests.Response
dominos/api.py
def reset_store(self): ''' Clears out the current store and gets a cookie. Set the cross site request forgery token for each subsequent request. :return: A response having cleared the current store. :rtype: requests.Response ''' response = self.__get('/Store/Rese...
def reset_store(self): ''' Clears out the current store and gets a cookie. Set the cross site request forgery token for each subsequent request. :return: A response having cleared the current store. :rtype: requests.Response ''' response = self.__get('/Store/Rese...
[ "Clears", "out", "the", "current", "store", "and", "gets", "a", "cookie", ".", "Set", "the", "cross", "site", "request", "forgery", "token", "for", "each", "subsequent", "request", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L43-L56
[ "def", "reset_store", "(", "self", ")", ":", "response", "=", "self", ".", "__get", "(", "'/Store/Reset'", ")", "token", "=", "self", ".", "session", ".", "cookies", "[", "'XSRF-TOKEN'", "]", "self", ".", "session", ".", "headers", ".", "update", "(", ...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.get_stores
Search for dominos pizza stores using a search term. :param string search: Search term. :return: A list of nearby stores matching the search term. :rtype: list
dominos/api.py
def get_stores(self, search_term): ''' Search for dominos pizza stores using a search term. :param string search: Search term. :return: A list of nearby stores matching the search term. :rtype: list ''' params = {'SearchText': search_term} response = self...
def get_stores(self, search_term): ''' Search for dominos pizza stores using a search term. :param string search: Search term. :return: A list of nearby stores matching the search term. :rtype: list ''' params = {'SearchText': search_term} response = self...
[ "Search", "for", "dominos", "pizza", "stores", "using", "a", "search", "term", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L58-L69
[ "def", "get_stores", "(", "self", ",", "search_term", ")", ":", "params", "=", "{", "'SearchText'", ":", "search_term", "}", "response", "=", "self", ".", "__get", "(", "'/storefindermap/storesearch'", ",", "params", "=", "params", ")", "return", "Stores", "...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.set_delivery_system
Set local cookies by initialising the delivery system on the remote. Requires a store ID and a delivery postcode. :param Store store: Store id. :param string postcode: A postcode. :return: A response having initialised the delivery system. :rtype: requests.Response
dominos/api.py
def set_delivery_system(self, store, postcode, fulfilment_method=FULFILMENT_METHOD.DELIVERY): ''' Set local cookies by initialising the delivery system on the remote. Requires a store ID and a delivery postcode. :param Store store: Store id. :param string postcode: A postcode. ...
def set_delivery_system(self, store, postcode, fulfilment_method=FULFILMENT_METHOD.DELIVERY): ''' Set local cookies by initialising the delivery system on the remote. Requires a store ID and a delivery postcode. :param Store store: Store id. :param string postcode: A postcode. ...
[ "Set", "local", "cookies", "by", "initialising", "the", "delivery", "system", "on", "the", "remote", ".", "Requires", "a", "store", "ID", "and", "a", "delivery", "postcode", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L82-L100
[ "def", "set_delivery_system", "(", "self", ",", "store", ",", "postcode", ",", "fulfilment_method", "=", "FULFILMENT_METHOD", ".", "DELIVERY", ")", ":", "method", "=", "'delivery'", "if", "fulfilment_method", "==", "FULFILMENT_METHOD", ".", "DELIVERY", "else", "'c...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.get_menu
Retrieve the menu from the selected store. :param Store store: A store. :return: The store menu. :rtype: Menu
dominos/api.py
def get_menu(self, store): ''' Retrieve the menu from the selected store. :param Store store: A store. :return: The store menu. :rtype: Menu ''' params = { 'collectionOnly': not store.delivery_available, 'menuVersion': store.menu_version, ...
def get_menu(self, store): ''' Retrieve the menu from the selected store. :param Store store: A store. :return: The store menu. :rtype: Menu ''' params = { 'collectionOnly': not store.delivery_available, 'menuVersion': store.menu_version, ...
[ "Retrieve", "the", "menu", "from", "the", "selected", "store", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L102-L117
[ "def", "get_menu", "(", "self", ",", "store", ")", ":", "params", "=", "{", "'collectionOnly'", ":", "not", "store", ".", "delivery_available", ",", "'menuVersion'", ":", "store", ".", "menu_version", ",", "'storeId'", ":", "store", ".", "store_id", ",", "...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.add_item_to_basket
Add an item to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Ignored if the item is a side. :param int quantity: The quantity of item to be added. :return: A response having added an item to the current basket. :rtype: requests.Response
dominos/api.py
def add_item_to_basket(self, item, variant=VARIANT.MEDIUM, quantity=1): ''' Add an item to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Ignored if the item is a side. :param int quantity: The quantity of item to be added. :return...
def add_item_to_basket(self, item, variant=VARIANT.MEDIUM, quantity=1): ''' Add an item to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Ignored if the item is a side. :param int quantity: The quantity of item to be added. :return...
[ "Add", "an", "item", "to", "the", "current", "basket", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L129-L145
[ "def", "add_item_to_basket", "(", "self", ",", "item", ",", "variant", "=", "VARIANT", ".", "MEDIUM", ",", "quantity", "=", "1", ")", ":", "item_type", "=", "item", ".", "type", "if", "item_type", "==", "'Pizza'", ":", "return", "self", ".", "add_pizza_t...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.add_pizza_to_basket
Add a pizza to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Some defaults are defined in the VARIANT enum. :param int quantity: The quantity of pizza to be added. :return: A response having added a pizza to the current basket. :rtype: re...
dominos/api.py
def add_pizza_to_basket(self, item, variant=VARIANT.MEDIUM, quantity=1): ''' Add a pizza to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Some defaults are defined in the VARIANT enum. :param int quantity: The quantity of pizza to be adde...
def add_pizza_to_basket(self, item, variant=VARIANT.MEDIUM, quantity=1): ''' Add a pizza to the current basket. :param Item item: Item from menu. :param int variant: Item SKU id. Some defaults are defined in the VARIANT enum. :param int quantity: The quantity of pizza to be adde...
[ "Add", "a", "pizza", "to", "the", "current", "basket", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L147-L171
[ "def", "add_pizza_to_basket", "(", "self", ",", "item", ",", "variant", "=", "VARIANT", ".", "MEDIUM", ",", "quantity", "=", "1", ")", ":", "item_variant", "=", "item", "[", "variant", "]", "ingredients", "=", "item_variant", "[", "'ingredients'", "]", "."...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.add_side_to_basket
Add a side to the current basket. :param Item item: Item from menu. :param int quantity: The quantity of side to be added. :return: A response having added a side to the current basket. :rtype: requests.Response
dominos/api.py
def add_side_to_basket(self, item, quantity=1): ''' Add a side to the current basket. :param Item item: Item from menu. :param int quantity: The quantity of side to be added. :return: A response having added a side to the current basket. :rtype: requests.Response ...
def add_side_to_basket(self, item, quantity=1): ''' Add a side to the current basket. :param Item item: Item from menu. :param int quantity: The quantity of side to be added. :return: A response having added a side to the current basket. :rtype: requests.Response ...
[ "Add", "a", "side", "to", "the", "current", "basket", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L173-L190
[ "def", "add_side_to_basket", "(", "self", ",", "item", ",", "quantity", "=", "1", ")", ":", "item_variant", "=", "item", "[", "VARIANT", ".", "PERSONAL", "]", "params", "=", "{", "'productSkuId'", ":", "item_variant", "[", "'productSkuId'", "]", ",", "'qua...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.remove_item_from_basket
Remove an item from the current basket. :param int idx: Basket item id. :return: A response having removed an item from the current basket. :rtype: requests.Response
dominos/api.py
def remove_item_from_basket(self, idx): ''' Remove an item from the current basket. :param int idx: Basket item id. :return: A response having removed an item from the current basket. :rtype: requests.Response ''' params = { 'basketItemId': idx, ...
def remove_item_from_basket(self, idx): ''' Remove an item from the current basket. :param int idx: Basket item id. :return: A response having removed an item from the current basket. :rtype: requests.Response ''' params = { 'basketItemId': idx, ...
[ "Remove", "an", "item", "from", "the", "current", "basket", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L192-L205
[ "def", "remove_item_from_basket", "(", "self", ",", "idx", ")", ":", "params", "=", "{", "'basketItemId'", ":", "idx", ",", "'wizardItemDelete'", ":", "False", "}", "return", "self", ".", "__post", "(", "'/Basket/RemoveBasketItem'", ",", "json", "=", "params",...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.set_payment_method
Select the payment method going to be used to make a purchase. :param int method: Payment method id. :return: A response having set the payment option. :rtype: requests.Response
dominos/api.py
def set_payment_method(self, method=PAYMENT_METHOD.CASH_ON_DELIVERY): ''' Select the payment method going to be used to make a purchase. :param int method: Payment method id. :return: A response having set the payment option. :rtype: requests.Response ''' params ...
def set_payment_method(self, method=PAYMENT_METHOD.CASH_ON_DELIVERY): ''' Select the payment method going to be used to make a purchase. :param int method: Payment method id. :return: A response having set the payment option. :rtype: requests.Response ''' params ...
[ "Select", "the", "payment", "method", "going", "to", "be", "used", "to", "make", "a", "purchase", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L207-L216
[ "def", "set_payment_method", "(", "self", ",", "method", "=", "PAYMENT_METHOD", ".", "CASH_ON_DELIVERY", ")", ":", "params", "=", "{", "'paymentMethod'", ":", "method", "}", "return", "self", ".", "__post", "(", "'/PaymentOptions/SetPaymentMethod'", ",", "json", ...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.process_payment
Proceed with payment using the payment method selected earlier. :return: A response having processes the payment. :rtype: requests.Response
dominos/api.py
def process_payment(self): ''' Proceed with payment using the payment method selected earlier. :return: A response having processes the payment. :rtype: requests.Response ''' params = { '__RequestVerificationToken': self.session.cookies, 'method':...
def process_payment(self): ''' Proceed with payment using the payment method selected earlier. :return: A response having processes the payment. :rtype: requests.Response ''' params = { '__RequestVerificationToken': self.session.cookies, 'method':...
[ "Proceed", "with", "payment", "using", "the", "payment", "method", "selected", "earlier", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L224-L236
[ "def", "process_payment", "(", "self", ")", ":", "params", "=", "{", "'__RequestVerificationToken'", ":", "self", ".", "session", ".", "cookies", ",", "'method'", ":", "'submit'", "}", "return", "self", ".", "__post", "(", "'/PaymentOptions/Proceed'", ",", "js...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.__get
Make a HTTP GET request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. :rtype: response.Response
dominos/api.py
def __get(self, path, **kargs): ''' Make a HTTP GET request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. :...
def __get(self, path, **kargs): ''' Make a HTTP GET request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. :...
[ "Make", "a", "HTTP", "GET", "request", "to", "the", "Dominos", "UK", "API", "with", "the", "given", "parameters", "for", "the", "current", "session", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L238-L248
[ "def", "__get", "(", "self", ",", "path", ",", "*", "*", "kargs", ")", ":", "return", "self", ".", "__call_api", "(", "self", ".", "session", ".", "get", ",", "path", ",", "*", "*", "kargs", ")" ]
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.__post
Make a HTTP POST request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. :rtype: response.Response
dominos/api.py
def __post(self, path, **kargs): ''' Make a HTTP POST request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. ...
def __post(self, path, **kargs): ''' Make a HTTP POST request to the Dominos UK API with the given parameters for the current session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. ...
[ "Make", "a", "HTTP", "POST", "request", "to", "the", "Dominos", "UK", "API", "with", "the", "given", "parameters", "for", "the", "current", "session", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L250-L260
[ "def", "__post", "(", "self", ",", "path", ",", "*", "*", "kargs", ")", ":", "return", "self", ".", "__call_api", "(", "self", ".", "session", ".", "post", ",", "path", ",", "*", "*", "kargs", ")" ]
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
Client.__call_api
Make a HTTP request to the Dominos UK API with the given parameters for the current session. :param verb func: HTTP method on the session. :param string path: The API endpoint path. :params list kargs: A list of arguments. :return: A response from the Dominos UK API. :rt...
dominos/api.py
def __call_api(self, verb, path, **kargs): ''' Make a HTTP request to the Dominos UK API with the given parameters for the current session. :param verb func: HTTP method on the session. :param string path: The API endpoint path. :params list kargs: A list of arguments. ...
def __call_api(self, verb, path, **kargs): ''' Make a HTTP request to the Dominos UK API with the given parameters for the current session. :param verb func: HTTP method on the session. :param string path: The API endpoint path. :params list kargs: A list of arguments. ...
[ "Make", "a", "HTTP", "request", "to", "the", "Dominos", "UK", "API", "with", "the", "given", "parameters", "for", "the", "current", "session", "." ]
tomasbasham/dominos
python
https://github.com/tomasbasham/dominos/blob/59729a8bdca0ae30a84115a0e93e9b1f259faf0e/dominos/api.py#L264-L280
[ "def", "__call_api", "(", "self", ",", "verb", ",", "path", ",", "*", "*", "kargs", ")", ":", "response", "=", "verb", "(", "self", ".", "__url", "(", "path", ")", ",", "*", "*", "kargs", ")", "if", "response", ".", "status_code", "!=", "200", ":...
59729a8bdca0ae30a84115a0e93e9b1f259faf0e
test
CursesMenu.append_item
Add an item to the end of the menu before the exit item :param MenuItem item: The item to be added
cursesmenu/curses_menu.py
def append_item(self, item): """ Add an item to the end of the menu before the exit item :param MenuItem item: The item to be added """ did_remove = self.remove_exit() item.menu = self self.items.append(item) if did_remove: self.add_exit() ...
def append_item(self, item): """ Add an item to the end of the menu before the exit item :param MenuItem item: The item to be added """ did_remove = self.remove_exit() item.menu = self self.items.append(item) if did_remove: self.add_exit() ...
[ "Add", "an", "item", "to", "the", "end", "of", "the", "menu", "before", "the", "exit", "item" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L88-L103
[ "def", "append_item", "(", "self", ",", "item", ")", ":", "did_remove", "=", "self", ".", "remove_exit", "(", ")", "item", ".", "menu", "=", "self", "self", ".", "items", ".", "append", "(", "item", ")", "if", "did_remove", ":", "self", ".", "add_exi...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
CursesMenu.add_exit
Add the exit item if necessary. Used to make sure there aren't multiple exit items :return: True if item needed to be added, False otherwise :rtype: bool
cursesmenu/curses_menu.py
def add_exit(self): """ Add the exit item if necessary. Used to make sure there aren't multiple exit items :return: True if item needed to be added, False otherwise :rtype: bool """ if self.items: if self.items[-1] is not self.exit_item: self....
def add_exit(self): """ Add the exit item if necessary. Used to make sure there aren't multiple exit items :return: True if item needed to be added, False otherwise :rtype: bool """ if self.items: if self.items[-1] is not self.exit_item: self....
[ "Add", "the", "exit", "item", "if", "necessary", ".", "Used", "to", "make", "sure", "there", "aren", "t", "multiple", "exit", "items" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L105-L116
[ "def", "add_exit", "(", "self", ")", ":", "if", "self", ".", "items", ":", "if", "self", ".", "items", "[", "-", "1", "]", "is", "not", "self", ".", "exit_item", ":", "self", ".", "items", ".", "append", "(", "self", ".", "exit_item", ")", "retur...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
CursesMenu.draw
Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn.
cursesmenu/curses_menu.py
def draw(self): """ Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn. """ self.screen.border(0) if self.title is not None: self.screen.addstr(2, 2, self.title, curses.A_STANDOUT) if self.subtitle ...
def draw(self): """ Redraws the menu and refreshes the screen. Should be called whenever something changes that needs to be redrawn. """ self.screen.border(0) if self.title is not None: self.screen.addstr(2, 2, self.title, curses.A_STANDOUT) if self.subtitle ...
[ "Redraws", "the", "menu", "and", "refreshes", "the", "screen", ".", "Should", "be", "called", "whenever", "something", "changes", "that", "needs", "to", "be", "redrawn", "." ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L195-L221
[ "def", "draw", "(", "self", ")", ":", "self", ".", "screen", ".", "border", "(", "0", ")", "if", "self", ".", "title", "is", "not", "None", ":", "self", ".", "screen", ".", "addstr", "(", "2", ",", "2", ",", "self", ".", "title", ",", "curses",...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
CursesMenu.process_user_input
Gets the next single character and decides what to do with it
cursesmenu/curses_menu.py
def process_user_input(self): """ Gets the next single character and decides what to do with it """ user_input = self.get_input() go_to_max = ord("9") if len(self.items) >= 9 else ord(str(len(self.items))) if ord('1') <= user_input <= go_to_max: self.go_to(u...
def process_user_input(self): """ Gets the next single character and decides what to do with it """ user_input = self.get_input() go_to_max = ord("9") if len(self.items) >= 9 else ord(str(len(self.items))) if ord('1') <= user_input <= go_to_max: self.go_to(u...
[ "Gets", "the", "next", "single", "character", "and", "decides", "what", "to", "do", "with", "it" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L274-L291
[ "def", "process_user_input", "(", "self", ")", ":", "user_input", "=", "self", ".", "get_input", "(", ")", "go_to_max", "=", "ord", "(", "\"9\"", ")", "if", "len", "(", "self", ".", "items", ")", ">=", "9", "else", "ord", "(", "str", "(", "len", "(...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
CursesMenu.select
Select the current item and run it
cursesmenu/curses_menu.py
def select(self): """ Select the current item and run it """ self.selected_option = self.current_option self.selected_item.set_up() self.selected_item.action() self.selected_item.clean_up() self.returned_value = self.selected_item.get_return() self...
def select(self): """ Select the current item and run it """ self.selected_option = self.current_option self.selected_item.set_up() self.selected_item.action() self.selected_item.clean_up() self.returned_value = self.selected_item.get_return() self...
[ "Select", "the", "current", "item", "and", "run", "it" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L323-L335
[ "def", "select", "(", "self", ")", ":", "self", ".", "selected_option", "=", "self", ".", "current_option", "self", ".", "selected_item", ".", "set_up", "(", ")", "self", ".", "selected_item", ".", "action", "(", ")", "self", ".", "selected_item", ".", "...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
ExitItem.show
This class overrides this method
cursesmenu/curses_menu.py
def show(self, index): """ This class overrides this method """ if self.menu and self.menu.parent: self.text = "Return to %s menu" % self.menu.parent.title else: self.text = "Exit" return super(ExitItem, self).show(index)
def show(self, index): """ This class overrides this method """ if self.menu and self.menu.parent: self.text = "Return to %s menu" % self.menu.parent.title else: self.text = "Exit" return super(ExitItem, self).show(index)
[ "This", "class", "overrides", "this", "method" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/curses_menu.py#L424-L432
[ "def", "show", "(", "self", ",", "index", ")", ":", "if", "self", ".", "menu", "and", "self", ".", "menu", ".", "parent", ":", "self", ".", "text", "=", "\"Return to %s menu\"", "%", "self", ".", "menu", ".", "parent", ".", "title", "else", ":", "s...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
FunctionItem.action
This class overrides this method
cursesmenu/items/function_item.py
def action(self): """ This class overrides this method """ self.return_value = self.function(*self.args, **self.kwargs)
def action(self): """ This class overrides this method """ self.return_value = self.function(*self.args, **self.kwargs)
[ "This", "class", "overrides", "this", "method" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/items/function_item.py#L31-L35
[ "def", "action", "(", "self", ")", ":", "self", ".", "return_value", "=", "self", ".", "function", "(", "*", "self", ".", "args", ",", "*", "*", "self", ".", "kwargs", ")" ]
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
CommandItem.action
This class overrides this method
cursesmenu/items/command_item.py
def action(self): """ This class overrides this method """ commandline = "{0} {1}".format(self.command, " ".join(self.arguments)) try: completed_process = subprocess.run(commandline, shell=True) self.exit_status = completed_process.returncode excep...
def action(self): """ This class overrides this method """ commandline = "{0} {1}".format(self.command, " ".join(self.arguments)) try: completed_process = subprocess.run(commandline, shell=True) self.exit_status = completed_process.returncode excep...
[ "This", "class", "overrides", "this", "method" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/items/command_item.py#L27-L36
[ "def", "action", "(", "self", ")", ":", "commandline", "=", "\"{0} {1}\"", ".", "format", "(", "self", ".", "command", ",", "\" \"", ".", "join", "(", "self", ".", "arguments", ")", ")", "try", ":", "completed_process", "=", "subprocess", ".", "run", "...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
parse_old_menu
Take an old-style menuData dictionary and return a CursesMenu :param dict menu_data: :return: A new CursesMenu :rtype: CursesMenu
cursesmenu/old_curses_menu.py
def parse_old_menu(menu_data): """ Take an old-style menuData dictionary and return a CursesMenu :param dict menu_data: :return: A new CursesMenu :rtype: CursesMenu """ menu_title = menu_data['title'] menu = CursesMenu(menu_title) for item in menu_data["options"]: item_type ...
def parse_old_menu(menu_data): """ Take an old-style menuData dictionary and return a CursesMenu :param dict menu_data: :return: A new CursesMenu :rtype: CursesMenu """ menu_title = menu_data['title'] menu = CursesMenu(menu_title) for item in menu_data["options"]: item_type ...
[ "Take", "an", "old", "-", "style", "menuData", "dictionary", "and", "return", "a", "CursesMenu" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/old_curses_menu.py#L20-L47
[ "def", "parse_old_menu", "(", "menu_data", ")", ":", "menu_title", "=", "menu_data", "[", "'title'", "]", "menu", "=", "CursesMenu", "(", "menu_title", ")", "for", "item", "in", "menu_data", "[", "\"options\"", "]", ":", "item_type", "=", "item", "[", "\"t...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
SubmenuItem.set_up
This class overrides this method
cursesmenu/items/submenu_item.py
def set_up(self): """ This class overrides this method """ self.menu.pause() curses.def_prog_mode() self.menu.clear_screen()
def set_up(self): """ This class overrides this method """ self.menu.pause() curses.def_prog_mode() self.menu.clear_screen()
[ "This", "class", "overrides", "this", "method" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/items/submenu_item.py#L31-L37
[ "def", "set_up", "(", "self", ")", ":", "self", ".", "menu", ".", "pause", "(", ")", "curses", ".", "def_prog_mode", "(", ")", "self", ".", "menu", ".", "clear_screen", "(", ")" ]
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
SubmenuItem.clean_up
This class overrides this method
cursesmenu/items/submenu_item.py
def clean_up(self): """ This class overrides this method """ self.submenu.join() self.menu.clear_screen() curses.reset_prog_mode() curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) self.menu.resume()
def clean_up(self): """ This class overrides this method """ self.submenu.join() self.menu.clear_screen() curses.reset_prog_mode() curses.curs_set(1) # reset doesn't do this right curses.curs_set(0) self.menu.resume()
[ "This", "class", "overrides", "this", "method" ]
pmbarrett314/curses-menu
python
https://github.com/pmbarrett314/curses-menu/blob/c76fc00ab9d518eab275e55434fc2941f49c6b30/cursesmenu/items/submenu_item.py#L45-L54
[ "def", "clean_up", "(", "self", ")", ":", "self", ".", "submenu", ".", "join", "(", ")", "self", ".", "menu", ".", "clear_screen", "(", ")", "curses", ".", "reset_prog_mode", "(", ")", "curses", ".", "curs_set", "(", "1", ")", "# reset doesn't do this ri...
c76fc00ab9d518eab275e55434fc2941f49c6b30
test
add_aggregation_columns
Add new columns containing aggregations values on existing columns --- ### Parameters *mandatory :* - `group_cols` (*str* or *list*): columns used to aggregate the data - `aggregations` (*dict*): keys are name of new columns and values are aggregation functions Examples of aggregation func...
toucan_data_sdk/utils/postprocess/add_aggregation_columns.py
def add_aggregation_columns( df, *, group_cols: Union[str, List[str]], aggregations: Dict[str, Agg] ): """ Add new columns containing aggregations values on existing columns --- ### Parameters *mandatory :* - `group_cols` (*str* or *list*): columns used to aggregate th...
def add_aggregation_columns( df, *, group_cols: Union[str, List[str]], aggregations: Dict[str, Agg] ): """ Add new columns containing aggregations values on existing columns --- ### Parameters *mandatory :* - `group_cols` (*str* or *list*): columns used to aggregate th...
[ "Add", "new", "columns", "containing", "aggregations", "values", "on", "existing", "columns" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/add_aggregation_columns.py#L6-L74
[ "def", "add_aggregation_columns", "(", "df", ",", "*", ",", "group_cols", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "aggregations", ":", "Dict", "[", "str", ",", "Agg", "]", ")", ":", "group", "=", "df", ".", "groupby", "(",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
top
Get the top or flop N results based on a column value for each specified group columns --- ### Parameters *mandatory :* - `value` (*str*): column name on which you will rank the results - `limit` (*int*): Number to specify the N results you want to retrieve. Use a positive number x to ret...
toucan_data_sdk/utils/postprocess/top.py
def top( df, value: str, limit: int, order: str = 'asc', group: Union[str, List[str]] = None ): """ Get the top or flop N results based on a column value for each specified group columns --- ### Parameters *mandatory :* - `value` (*str*): column name on...
def top( df, value: str, limit: int, order: str = 'asc', group: Union[str, List[str]] = None ): """ Get the top or flop N results based on a column value for each specified group columns --- ### Parameters *mandatory :* - `value` (*str*): column name on...
[ "Get", "the", "top", "or", "flop", "N", "results", "based", "on", "a", "column", "value", "for", "each", "specified", "group", "columns" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/top.py#L4-L77
[ "def", "top", "(", "df", ",", "value", ":", "str", ",", "limit", ":", "int", ",", "order", ":", "str", "=", "'asc'", ",", "group", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ")", ":", "ascending", "=", "order", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
top_group
Get the top or flop N results based on a function and a column value that agregates the input. The result is composed by all the original lines including only lines corresponding to the top groups --- ### Parameters *mandatory :* - `value` (*str*): Name of the column name on which you will ra...
toucan_data_sdk/utils/postprocess/top.py
def top_group( df, aggregate_by: List[str], value: str, limit: int, order: str = 'asc', function: str = 'sum', group: Union[str, List[str]] = None ): """ Get the top or flop N results based on a function and a column value that agregates the input. The...
def top_group( df, aggregate_by: List[str], value: str, limit: int, order: str = 'asc', function: str = 'sum', group: Union[str, List[str]] = None ): """ Get the top or flop N results based on a function and a column value that agregates the input. The...
[ "Get", "the", "top", "or", "flop", "N", "results", "based", "on", "a", "function", "and", "a", "column", "value", "that", "agregates", "the", "input", ".", "The", "result", "is", "composed", "by", "all", "the", "original", "lines", "including", "only", "...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/top.py#L80-L158
[ "def", "top_group", "(", "df", ",", "aggregate_by", ":", "List", "[", "str", "]", ",", "value", ":", "str", ",", "limit", ":", "int", ",", "order", ":", "str", "=", "'asc'", ",", "function", ":", "str", "=", "'sum'", ",", "group", ":", "Union", "...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
convert_str_to_datetime
Convert string column into datetime column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to format - `format` (*str*): current format of the values (see [available formats]( https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior))
toucan_data_sdk/utils/postprocess/converter.py
def convert_str_to_datetime(df, *, column: str, format: str): """ Convert string column into datetime column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to format - `format` (*str*): current format of the values (see [available formats]( https://docs.python...
def convert_str_to_datetime(df, *, column: str, format: str): """ Convert string column into datetime column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to format - `format` (*str*): current format of the values (see [available formats]( https://docs.python...
[ "Convert", "string", "column", "into", "datetime", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/converter.py#L4-L18
[ "def", "convert_str_to_datetime", "(", "df", ",", "*", ",", "column", ":", "str", ",", "format", ":", "str", ")", ":", "df", "[", "column", "]", "=", "pd", ".", "to_datetime", "(", "df", "[", "column", "]", ",", "format", "=", "format", ")", "retur...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
convert_datetime_to_str
Convert datetime column into string column --- ### Parameters *mandatory :* - column (*str*): name of the column to format - format (*str*): format of the result values (see [available formats]( https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)) *optional :*...
toucan_data_sdk/utils/postprocess/converter.py
def convert_datetime_to_str(df, *, column: str, format: str, new_column: str = None): """ Convert datetime column into string column --- ### Parameters *mandatory :* - column (*str*): name of the column to format - format (*str*): format of the result values (see [available formats]( ...
def convert_datetime_to_str(df, *, column: str, format: str, new_column: str = None): """ Convert datetime column into string column --- ### Parameters *mandatory :* - column (*str*): name of the column to format - format (*str*): format of the result values (see [available formats]( ...
[ "Convert", "datetime", "column", "into", "string", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/converter.py#L21-L39
[ "def", "convert_datetime_to_str", "(", "df", ",", "*", ",", "column", ":", "str", ",", "format", ":", "str", ",", "new_column", ":", "str", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "column", "df", "[", "new_column", "]", "=", "df",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
change_date_format
Convert the format of a date --- ### Parameters *mandatory :* - `column` (*str*): name of the column to change the format - `output_format` (*str*): format of the output values (see [available formats]( https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior)) *opt...
toucan_data_sdk/utils/postprocess/converter.py
def change_date_format( df, *, column: str, output_format: str, input_format: str = None, new_column: str = None, new_time_zone=None ): """ Convert the format of a date --- ### Parameters *mandatory :* - `column` (*str*): name of the column to c...
def change_date_format( df, *, column: str, output_format: str, input_format: str = None, new_column: str = None, new_time_zone=None ): """ Convert the format of a date --- ### Parameters *mandatory :* - `column` (*str*): name of the column to c...
[ "Convert", "the", "format", "of", "a", "date" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/converter.py#L42-L96
[ "def", "change_date_format", "(", "df", ",", "*", ",", "column", ":", "str", ",", "output_format", ":", "str", ",", "input_format", ":", "str", "=", "None", ",", "new_column", ":", "str", "=", "None", ",", "new_time_zone", "=", "None", ")", ":", "new_c...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
cast
Convert column's type into type --- ### Parameters *mandatory :* - `column` (*str*): name of the column to convert - `type` (*str*): output type. It can be : - `"int"` : integer type - `"float"` : general number type - `"str"` : text type *optional :* - `new_colum...
toucan_data_sdk/utils/postprocess/converter.py
def cast(df, column: str, type: str, new_column=None): """ Convert column's type into type --- ### Parameters *mandatory :* - `column` (*str*): name of the column to convert - `type` (*str*): output type. It can be : - `"int"` : integer type - `"float"` : general number ty...
def cast(df, column: str, type: str, new_column=None): """ Convert column's type into type --- ### Parameters *mandatory :* - `column` (*str*): name of the column to convert - `type` (*str*): output type. It can be : - `"int"` : integer type - `"float"` : general number ty...
[ "Convert", "column", "s", "type", "into", "type" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/converter.py#L99-L154
[ "def", "cast", "(", "df", ",", "column", ":", "str", ",", "type", ":", "str", ",", "new_column", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "column", "df", "[", "new_column", "]", "=", "df", "[", "column", "]", ".", "astype", "("...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
compute_evolution_by_frequency
This function answers the question: how has a value changed on a weekly, monthly, yearly basis ? --- ### Parameters *mandatory :* - `id_cols` (*list*): name of the columns used to create each group. - `date_col` (*str or dict*): either directly the name of the column containing the date or a dict...
toucan_data_sdk/utils/generic/compute_evolution.py
def compute_evolution_by_frequency( df, id_cols: List[str], date_col: Union[str, Dict[str, str]], value_col: str, freq=1, method: str = 'abs', format: str = 'column', offseted_suffix: str = '_offseted', evolution_col_name: str = 'evolution_computed', missing_date_as_zero: bool = ...
def compute_evolution_by_frequency( df, id_cols: List[str], date_col: Union[str, Dict[str, str]], value_col: str, freq=1, method: str = 'abs', format: str = 'column', offseted_suffix: str = '_offseted', evolution_col_name: str = 'evolution_computed', missing_date_as_zero: bool = ...
[ "This", "function", "answers", "the", "question", ":", "how", "has", "a", "value", "changed", "on", "a", "weekly", "monthly", "yearly", "basis", "?" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_evolution.py#L10-L98
[ "def", "compute_evolution_by_frequency", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "date_col", ":", "Union", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", ",", "value_col", ":", "str", ",", "freq", "=", "1", ",", "m...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
compute_evolution_by_criteria
This function answers the question: how has a value changed compare to a specific value ? --- ### Parameters *mandatory :* - `id_cols` (*list*): columns used to create each group - `value_col` (*str*): name of the column containing the value to compare - `compare_to` (*str*): the query identi...
toucan_data_sdk/utils/generic/compute_evolution.py
def compute_evolution_by_criteria( df, id_cols: List[str], value_col: str, compare_to: str, method: str = 'abs', format: str = 'column', offseted_suffix: str = '_offseted', evolution_col_name: str = 'evolution_computed', raise_duplicate_error: bool = True ): """ This function...
def compute_evolution_by_criteria( df, id_cols: List[str], value_col: str, compare_to: str, method: str = 'abs', format: str = 'column', offseted_suffix: str = '_offseted', evolution_col_name: str = 'evolution_computed', raise_duplicate_error: bool = True ): """ This function...
[ "This", "function", "answers", "the", "question", ":", "how", "has", "a", "value", "changed", "compare", "to", "a", "specific", "value", "?" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_evolution.py#L101-L160
[ "def", "compute_evolution_by_criteria", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "value_col", ":", "str", ",", "compare_to", ":", "str", ",", "method", ":", "str", "=", "'abs'", ",", "format", ":", "str", "=", "'column'", ",", "off...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
__compute_evolution
Compute an evolution column : - against a period distant from a fixed frequency. - against a part of the df Unfortunately, pandas doesn't allow .change() and .pct_change() to be executed with a MultiIndex. Args: df (pd.DataFrame): id_cols (list(str)): value_col (str...
toucan_data_sdk/utils/generic/compute_evolution.py
def __compute_evolution( df, id_cols, value_col, date_col=None, freq=1, compare_to=None, method='abs', format='column', offseted_suffix='_offseted', evolution_col_name='evolution_computed', how='left', fillna=None, raise_duplicate_error=True ): """ Compute an ...
def __compute_evolution( df, id_cols, value_col, date_col=None, freq=1, compare_to=None, method='abs', format='column', offseted_suffix='_offseted', evolution_col_name='evolution_computed', how='left', fillna=None, raise_duplicate_error=True ): """ Compute an ...
[ "Compute", "an", "evolution", "column", ":", "-", "against", "a", "period", "distant", "from", "a", "fixed", "frequency", ".", "-", "against", "a", "part", "of", "the", "df" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_evolution.py#L167-L246
[ "def", "__compute_evolution", "(", "df", ",", "id_cols", ",", "value_col", ",", "date_col", "=", "None", ",", "freq", "=", "1", ",", "compare_to", "=", "None", ",", "method", "=", "'abs'", ",", "format", "=", "'column'", ",", "offseted_suffix", "=", "'_o...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
rank
This function creates rank columns based on numeric values to be ranked. --- ### Parameters *mandatory :* - `value_cols` (*list*): name(s) of the columns used *optional :* - `group_cols` (*list*): name(s) of the column(s) used to create each group inside which independent ranking needs...
toucan_data_sdk/utils/postprocess/rank.py
def rank( df, value_cols: Union[str, List[str]], group_cols: List[str] = None, rank_cols_names: List[str] = None, method='min', ascending: bool = True ): """ This function creates rank columns based on numeric values to be ranked. --- ### Parameters ...
def rank( df, value_cols: Union[str, List[str]], group_cols: List[str] = None, rank_cols_names: List[str] = None, method='min', ascending: bool = True ): """ This function creates rank columns based on numeric values to be ranked. --- ### Parameters ...
[ "This", "function", "creates", "rank", "columns", "based", "on", "numeric", "values", "to", "be", "ranked", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/rank.py#L6-L91
[ "def", "rank", "(", "df", ",", "value_cols", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "group_cols", ":", "List", "[", "str", "]", "=", "None", ",", "rank_cols_names", ":", "List", "[", "str", "]", "=", "None", ",", "metho...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
waterfall
Return a line for each bars of a waterfall chart, totals, groups, subgroups. Compute the variation and variation rate for each line. --- ### Parameters *mandatory :* - `date` (*str*): name of the column that id the period of each lines - `value` (*str*): name of the column that contains the v...
toucan_data_sdk/utils/postprocess/waterfall.py
def waterfall( df, date: str, value: str, start: Dict[str, str], end: Dict[str, str], upperGroup: Dict[str, str], insideGroup: Dict[str, str] = None, filters: List[str] = None ): """ Return a line for each bars of a waterfall chart, totals, groups,...
def waterfall( df, date: str, value: str, start: Dict[str, str], end: Dict[str, str], upperGroup: Dict[str, str], insideGroup: Dict[str, str] = None, filters: List[str] = None ): """ Return a line for each bars of a waterfall chart, totals, groups,...
[ "Return", "a", "line", "for", "each", "bars", "of", "a", "waterfall", "chart", "totals", "groups", "subgroups", ".", "Compute", "the", "variation", "and", "variation", "rate", "for", "each", "line", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/waterfall.py#L5-L153
[ "def", "waterfall", "(", "df", ",", "date", ":", "str", ",", "value", ":", "str", ",", "start", ":", "Dict", "[", "str", ",", "str", "]", ",", "end", ":", "Dict", "[", "str", ",", "str", "]", ",", "upperGroup", ":", "Dict", "[", "str", ",", "...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_compute_start_end
Compute two dataframes with value for start and end Args: totals(dataframe): Returns: Dataframe, Dataframe
toucan_data_sdk/utils/postprocess/waterfall.py
def _compute_start_end(df, start, end): """ Compute two dataframes with value for start and end Args: totals(dataframe): Returns: Dataframe, Dataframe """ result = {} time_dict = {'start': start, 'end': end} totals = df.groupby('date').agg({'value': sum}).reset_index() for ...
def _compute_start_end(df, start, end): """ Compute two dataframes with value for start and end Args: totals(dataframe): Returns: Dataframe, Dataframe """ result = {} time_dict = {'start': start, 'end': end} totals = df.groupby('date').agg({'value': sum}).reset_index() for ...
[ "Compute", "two", "dataframes", "with", "value", "for", "start", "and", "end", "Args", ":", "totals", "(", "dataframe", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/waterfall.py#L174-L198
[ "def", "_compute_start_end", "(", "df", ",", "start", ",", "end", ")", ":", "result", "=", "{", "}", "time_dict", "=", "{", "'start'", ":", "start", ",", "'end'", ":", "end", "}", "totals", "=", "df", ".", "groupby", "(", "'date'", ")", ".", "agg",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_compute_value_diff
Compute diff value between start and end Args: df(dataframe): Returns: Dataframe
toucan_data_sdk/utils/postprocess/waterfall.py
def _compute_value_diff(df, start, end, groups): """ Compute diff value between start and end Args: df(dataframe): Returns: Dataframe """ start_values = df[df['date'] == start['id']].copy() end_values = df[df['date'] == end['id']].copy() merge_on = [] for key, group in gro...
def _compute_value_diff(df, start, end, groups): """ Compute diff value between start and end Args: df(dataframe): Returns: Dataframe """ start_values = df[df['date'] == start['id']].copy() end_values = df[df['date'] == end['id']].copy() merge_on = [] for key, group in gro...
[ "Compute", "diff", "value", "between", "start", "and", "end", "Args", ":", "df", "(", "dataframe", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/waterfall.py#L201-L227
[ "def", "_compute_value_diff", "(", "df", ",", "start", ",", "end", ",", "groups", ")", ":", "start_values", "=", "df", "[", "df", "[", "'date'", "]", "==", "start", "[", "'id'", "]", "]", ".", "copy", "(", ")", "end_values", "=", "df", "[", "df", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_compute_inside_group
Compute inside Group Args: df(dataframe): Returns: Dataframe
toucan_data_sdk/utils/postprocess/waterfall.py
def _compute_inside_group(df): """ Compute inside Group Args: df(dataframe): Returns: Dataframe """ inside_group = df.copy() inside_group['type'] = 'child' inside_group['variation'] = inside_group['value'] / inside_group[ 'value_start'] inside_group.drop(['upperGrou...
def _compute_inside_group(df): """ Compute inside Group Args: df(dataframe): Returns: Dataframe """ inside_group = df.copy() inside_group['type'] = 'child' inside_group['variation'] = inside_group['value'] / inside_group[ 'value_start'] inside_group.drop(['upperGrou...
[ "Compute", "inside", "Group", "Args", ":", "df", "(", "dataframe", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/waterfall.py#L230-L247
[ "def", "_compute_inside_group", "(", "df", ")", ":", "inside_group", "=", "df", ".", "copy", "(", ")", "inside_group", "[", "'type'", "]", "=", "'child'", "inside_group", "[", "'variation'", "]", "=", "inside_group", "[", "'value'", "]", "/", "inside_group",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_compute_upper_group
Compute upperGroup Args: df (Dataframe): Returns: Dataframe
toucan_data_sdk/utils/postprocess/waterfall.py
def _compute_upper_group(df): """ Compute upperGroup Args: df (Dataframe): Returns: Dataframe """ upper_group = df.groupby(['groups']).agg({ 'value': sum, 'value_start': sum, 'upperGroup_label': 'first', 'upperGroup_order': 'first' }).reset_index() ...
def _compute_upper_group(df): """ Compute upperGroup Args: df (Dataframe): Returns: Dataframe """ upper_group = df.groupby(['groups']).agg({ 'value': sum, 'value_start': sum, 'upperGroup_label': 'first', 'upperGroup_order': 'first' }).reset_index() ...
[ "Compute", "upperGroup", "Args", ":", "df", "(", "Dataframe", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/waterfall.py#L250-L270
[ "def", "_compute_upper_group", "(", "df", ")", ":", "upper_group", "=", "df", ".", "groupby", "(", "[", "'groups'", "]", ")", ".", "agg", "(", "{", "'value'", ":", "sum", ",", "'value_start'", ":", "sum", ",", "'upperGroup_label'", ":", "'first'", ",", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_basic_math_operation
Basic mathematical operation to apply operator on `column_1` and `column_2` Both can be either a number or the name of a column of `df` Will create a new column named `new_column`
toucan_data_sdk/utils/postprocess/math.py
def _basic_math_operation(df, new_column, column_1, column_2, op): """ Basic mathematical operation to apply operator on `column_1` and `column_2` Both can be either a number or the name of a column of `df` Will create a new column named `new_column` """ if not isinstance(column_1, (str, int, fl...
def _basic_math_operation(df, new_column, column_1, column_2, op): """ Basic mathematical operation to apply operator on `column_1` and `column_2` Both can be either a number or the name of a column of `df` Will create a new column named `new_column` """ if not isinstance(column_1, (str, int, fl...
[ "Basic", "mathematical", "operation", "to", "apply", "operator", "on", "column_1", "and", "column_2", "Both", "can", "be", "either", "a", "number", "or", "the", "name", "of", "a", "column", "of", "df", "Will", "create", "a", "new", "column", "named", "new_...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L7-L24
[ "def", "_basic_math_operation", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ",", "op", ")", ":", "if", "not", "isinstance", "(", "column_1", ",", "(", "str", ",", "int", ",", "float", ")", ")", ":", "raise", "TypeError", "(", "f'col...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
add
DEPRECATED - use `formula` instead
toucan_data_sdk/utils/postprocess/math.py
def add(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='add')
def add(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='add')
[ "DEPRECATED", "-", "use", "formula", "instead" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L27-L31
[ "def", "add", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ")", ":", "return", "_basic_math_operation", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ",", "op", "=", "'add'", ")" ]
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
subtract
DEPRECATED - use `formula` instead
toucan_data_sdk/utils/postprocess/math.py
def subtract(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='sub')
def subtract(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='sub')
[ "DEPRECATED", "-", "use", "formula", "instead" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L34-L38
[ "def", "subtract", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ")", ":", "return", "_basic_math_operation", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ",", "op", "=", "'sub'", ")" ]
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
multiply
DEPRECATED - use `formula` instead
toucan_data_sdk/utils/postprocess/math.py
def multiply(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='mul')
def multiply(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='mul')
[ "DEPRECATED", "-", "use", "formula", "instead" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L41-L45
[ "def", "multiply", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ")", ":", "return", "_basic_math_operation", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ",", "op", "=", "'mul'", ")" ]
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
divide
DEPRECATED - use `formula` instead
toucan_data_sdk/utils/postprocess/math.py
def divide(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='truediv')
def divide(df, new_column, column_1, column_2): """ DEPRECATED - use `formula` instead """ return _basic_math_operation(df, new_column, column_1, column_2, op='truediv')
[ "DEPRECATED", "-", "use", "formula", "instead" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L48-L52
[ "def", "divide", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ")", ":", "return", "_basic_math_operation", "(", "df", ",", "new_column", ",", "column_1", ",", "column_2", ",", "op", "=", "'truediv'", ")" ]
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
formula
Do mathematic operations on columns (add, subtract, multiply or divide) --- ### Parameters *mandatory:* - `new_column` (*str*): name of the output column - `formula` (*str*): Operation on column. Use name of column and special character: - `+` for addition - `-` for subtraction ...
toucan_data_sdk/utils/postprocess/math.py
def formula(df, *, new_column: str, formula: str): """ Do mathematic operations on columns (add, subtract, multiply or divide) --- ### Parameters *mandatory:* - `new_column` (*str*): name of the output column - `formula` (*str*): Operation on column. Use name of column and special charact...
def formula(df, *, new_column: str, formula: str): """ Do mathematic operations on columns (add, subtract, multiply or divide) --- ### Parameters *mandatory:* - `new_column` (*str*): name of the output column - `formula` (*str*): Operation on column. Use name of column and special charact...
[ "Do", "mathematic", "operations", "on", "columns", "(", "add", "subtract", "multiply", "or", "divide", ")" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L103-L188
[ "def", "formula", "(", "df", ",", "*", ",", "new_column", ":", "str", ",", "formula", ":", "str", ")", ":", "tokens", "=", "_parse_formula", "(", "formula", ")", "expression_splitted", "=", "[", "]", "for", "t", "in", "tokens", ":", "# To use a column na...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
round_values
Round each value of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to round - `decimals` (*int*): number of decimal to keeep *optional :* - `new_column` (*str*): name of the new column to create. By default, no new column will be created and `colum...
toucan_data_sdk/utils/postprocess/math.py
def round_values(df, *, column: str, decimals: int, new_column: str = None): """ Round each value of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to round - `decimals` (*int*): number of decimal to keeep *optional :* - `new_column` (*str*): nam...
def round_values(df, *, column: str, decimals: int, new_column: str = None): """ Round each value of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column to round - `decimals` (*int*): number of decimal to keeep *optional :* - `new_column` (*str*): nam...
[ "Round", "each", "value", "of", "a", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L195-L238
[ "def", "round_values", "(", "df", ",", "*", ",", "column", ":", "str", ",", "decimals", ":", "int", ",", "new_column", ":", "str", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "column", "df", "[", "new_column", "]", "=", "df", "[", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
absolute_values
Get the absolute numeric value of each element of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column *optional :* - `new_column` (*str*): name of the column containing the result. By default, no new column will be created and `column` will be replaced. ...
toucan_data_sdk/utils/postprocess/math.py
def absolute_values(df, *, column: str, new_column: str = None): """ Get the absolute numeric value of each element of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column *optional :* - `new_column` (*str*): name of the column containing the result. ...
def absolute_values(df, *, column: str, new_column: str = None): """ Get the absolute numeric value of each element of a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column *optional :* - `new_column` (*str*): name of the column containing the result. ...
[ "Get", "the", "absolute", "numeric", "value", "of", "each", "element", "of", "a", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/math.py#L241-L282
[ "def", "absolute_values", "(", "df", ",", "*", ",", "column", ":", "str", ",", "new_column", ":", "str", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "column", "df", "[", "new_column", "]", "=", "abs", "(", "df", "[", "column", "]", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
pivot
Pivot the data. Reverse operation of melting --- ### Parameters *mandatory :* - `index` (*list*): names of index columns. - `column` (*str*): column name to pivot on - `value` (*str*): column name containing the value to fill the pivoted df *optional :* - `agg_function` (*str*): aggr...
toucan_data_sdk/utils/postprocess/pivot.py
def pivot(df, index: List[str], column: str, value: str, agg_function: str = 'mean'): """ Pivot the data. Reverse operation of melting --- ### Parameters *mandatory :* - `index` (*list*): names of index columns. - `column` (*str*): column name to pivot on - `value` (*str*): column nam...
def pivot(df, index: List[str], column: str, value: str, agg_function: str = 'mean'): """ Pivot the data. Reverse operation of melting --- ### Parameters *mandatory :* - `index` (*list*): names of index columns. - `column` (*str*): column name to pivot on - `value` (*str*): column nam...
[ "Pivot", "the", "data", ".", "Reverse", "operation", "of", "melting" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/pivot.py#L6-L58
[ "def", "pivot", "(", "df", ",", "index", ":", "List", "[", "str", "]", ",", "column", ":", "str", ",", "value", ":", "str", ",", "agg_function", ":", "str", "=", "'mean'", ")", ":", "if", "df", ".", "dtypes", "[", "value", "]", ".", "type", "==...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
pivot_by_group
Pivot a dataframe by group of variables --- ### Parameters *mandatory :* * `variable` (*str*): name of the column used to create the groups. * `value` (*str*): name of the column containing the value to fill the pivoted df. * `new_columns` (*list of str*): names of the new columns. * `gro...
toucan_data_sdk/utils/postprocess/pivot.py
def pivot_by_group( df, variable, value, new_columns, groups, id_cols=None ): """ Pivot a dataframe by group of variables --- ### Parameters *mandatory :* * `variable` (*str*): name of the column used to create the groups. * `value` (*str*):...
def pivot_by_group( df, variable, value, new_columns, groups, id_cols=None ): """ Pivot a dataframe by group of variables --- ### Parameters *mandatory :* * `variable` (*str*): name of the column used to create the groups. * `value` (*str*):...
[ "Pivot", "a", "dataframe", "by", "group", "of", "variables" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/pivot.py#L61-L136
[ "def", "pivot_by_group", "(", "df", ",", "variable", ",", "value", ",", "new_columns", ",", "groups", ",", "id_cols", "=", "None", ")", ":", "if", "id_cols", "is", "None", ":", "index", "=", "[", "variable", "]", "else", ":", "index", "=", "[", "vari...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
groupby
Aggregate values by groups. --- ### Parameters *mandatory :* - `group_cols` (*list*): list of columns used to group data - `aggregations` (*dict*): dictionnary of values columns to group as keys and aggregation function to use as values (See the [list of aggregation functions]( https:...
toucan_data_sdk/utils/postprocess/groupby.py
def groupby(df, *, group_cols: Union[str, List[str]], aggregations: Dict[str, Union[str, List[str]]]): """ Aggregate values by groups. --- ### Parameters *mandatory :* - `group_cols` (*list*): list of columns used to group data - `aggregations` (*dict*): dictionnary of values ...
def groupby(df, *, group_cols: Union[str, List[str]], aggregations: Dict[str, Union[str, List[str]]]): """ Aggregate values by groups. --- ### Parameters *mandatory :* - `group_cols` (*list*): list of columns used to group data - `aggregations` (*dict*): dictionnary of values ...
[ "Aggregate", "values", "by", "groups", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/groupby.py#L4-L65
[ "def", "groupby", "(", "df", ",", "*", ",", "group_cols", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", ",", "aggregations", ":", "Dict", "[", "str", ",", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "]", ")", ":", "...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
cumsum
DEPRECATED - please use `compute_cumsum` instead
toucan_data_sdk/utils/postprocess/cumsum.py
def cumsum(df, new_column: str, column: str, index: list, date_column: str, date_format: str): """ DEPRECATED - please use `compute_cumsum` instead """ logging.getLogger(__name__).warning(f"DEPRECATED: use compute_cumsum") date_temp = '__date_temp__' if isinstance(index, str): index = [i...
def cumsum(df, new_column: str, column: str, index: list, date_column: str, date_format: str): """ DEPRECATED - please use `compute_cumsum` instead """ logging.getLogger(__name__).warning(f"DEPRECATED: use compute_cumsum") date_temp = '__date_temp__' if isinstance(index, str): index = [i...
[ "DEPRECATED", "-", "please", "use", "compute_cumsum", "instead" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/cumsum.py#L5-L21
[ "def", "cumsum", "(", "df", ",", "new_column", ":", "str", ",", "column", ":", "str", ",", "index", ":", "list", ",", "date_column", ":", "str", ",", "date_format", ":", "str", ")", ":", "logging", ".", "getLogger", "(", "__name__", ")", ".", "warnin...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
add_missing_row
Add missing row to a df base on a reference column --- ### Parameters *mandatory :* - `id_cols` (*list of str*): names of the columns used to create each group - `reference_col` (*str*): name of the column used to identify missing rows *optional :* - `complete_index` (*list* or *dict*): ...
toucan_data_sdk/utils/generic/add_missing_row.py
def add_missing_row( df: pd.DataFrame, id_cols: List[str], reference_col: str, complete_index: Union[Dict[str, str], List[str]] = None, method: str = None, cols_to_keep: List[str] = None ) -> pd.DataFrame: """ Add missing row to a df base on a reference column --- ### Parameter...
def add_missing_row( df: pd.DataFrame, id_cols: List[str], reference_col: str, complete_index: Union[Dict[str, str], List[str]] = None, method: str = None, cols_to_keep: List[str] = None ) -> pd.DataFrame: """ Add missing row to a df base on a reference column --- ### Parameter...
[ "Add", "missing", "row", "to", "a", "df", "base", "on", "a", "reference", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/add_missing_row.py#L11-L121
[ "def", "add_missing_row", "(", "df", ":", "pd", ".", "DataFrame", ",", "id_cols", ":", "List", "[", "str", "]", ",", "reference_col", ":", "str", ",", "complete_index", ":", "Union", "[", "Dict", "[", "str", ",", "str", "]", ",", "List", "[", "str", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
extract_zip
Returns: dict: Dict[str, DataFrame]
toucan_data_sdk/sdk.py
def extract_zip(zip_file_path): """ Returns: dict: Dict[str, DataFrame] """ dfs = {} with zipfile.ZipFile(zip_file_path, mode='r') as z_file: names = z_file.namelist() for name in names: content = z_file.read(name) _, tmp_file_path = tempfile.mkstemp()...
def extract_zip(zip_file_path): """ Returns: dict: Dict[str, DataFrame] """ dfs = {} with zipfile.ZipFile(zip_file_path, mode='r') as z_file: names = z_file.namelist() for name in names: content = z_file.read(name) _, tmp_file_path = tempfile.mkstemp()...
[ "Returns", ":", "dict", ":", "Dict", "[", "str", "DataFrame", "]" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/sdk.py#L173-L191
[ "def", "extract_zip", "(", "zip_file_path", ")", ":", "dfs", "=", "{", "}", "with", "zipfile", ".", "ZipFile", "(", "zip_file_path", ",", "mode", "=", "'r'", ")", "as", "z_file", ":", "names", "=", "z_file", ".", "namelist", "(", ")", "for", "name", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
extract
Args: data (str | byte): Returns: dict: Dict[str, DataFrame]
toucan_data_sdk/sdk.py
def extract(data): """ Args: data (str | byte): Returns: dict: Dict[str, DataFrame] """ _, tmp_file_path = tempfile.mkstemp() try: with open(tmp_file_path, 'wb') as tmp_file: tmp_file.write(data) if zipfile.is_zipfile(tmp_file_path): ret...
def extract(data): """ Args: data (str | byte): Returns: dict: Dict[str, DataFrame] """ _, tmp_file_path = tempfile.mkstemp() try: with open(tmp_file_path, 'wb') as tmp_file: tmp_file.write(data) if zipfile.is_zipfile(tmp_file_path): ret...
[ "Args", ":", "data", "(", "str", "|", "byte", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/sdk.py#L194-L213
[ "def", "extract", "(", "data", ")", ":", "_", ",", "tmp_file_path", "=", "tempfile", ".", "mkstemp", "(", ")", "try", ":", "with", "open", "(", "tmp_file_path", ",", "'wb'", ")", "as", "tmp_file", ":", "tmp_file", ".", "write", "(", "data", ")", "if"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
ToucanDataSdk.read_from_cache
Returns: dict: Dict[str, DataFrame]
toucan_data_sdk/sdk.py
def read_from_cache(self, domains=None): """ Returns: dict: Dict[str, DataFrame] """ logger.info(f'Reading data from cache ({self.EXTRACTION_CACHE_PATH})') if domains is not None and isinstance(domains, list): dfs = {domain: self.read_entry(domain) for dom...
def read_from_cache(self, domains=None): """ Returns: dict: Dict[str, DataFrame] """ logger.info(f'Reading data from cache ({self.EXTRACTION_CACHE_PATH})') if domains is not None and isinstance(domains, list): dfs = {domain: self.read_entry(domain) for dom...
[ "Returns", ":", "dict", ":", "Dict", "[", "str", "DataFrame", "]" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/sdk.py#L114-L125
[ "def", "read_from_cache", "(", "self", ",", "domains", "=", "None", ")", ":", "logger", ".", "info", "(", "f'Reading data from cache ({self.EXTRACTION_CACHE_PATH})'", ")", "if", "domains", "is", "not", "None", "and", "isinstance", "(", "domains", ",", "list", ")...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
ToucanDataSdk.read_entry
Args: file_name (str): Returns: pd.DataFrame:
toucan_data_sdk/sdk.py
def read_entry(self, file_name): """ Args: file_name (str): Returns: pd.DataFrame: """ file_path = os.path.join(self.EXTRACTION_CACHE_PATH, file_name) logger.info(f'Reading cache entry: {file_path}') return joblib.load(file_path)
def read_entry(self, file_name): """ Args: file_name (str): Returns: pd.DataFrame: """ file_path = os.path.join(self.EXTRACTION_CACHE_PATH, file_name) logger.info(f'Reading cache entry: {file_path}') return joblib.load(file_path)
[ "Args", ":", "file_name", "(", "str", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/sdk.py#L127-L137
[ "def", "read_entry", "(", "self", ",", "file_name", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "EXTRACTION_CACHE_PATH", ",", "file_name", ")", "logger", ".", "info", "(", "f'Reading cache entry: {file_path}'", ")", "return", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
ToucanDataSdk.write
Args: data (str | byte): Returns: dict: Dict[str, DataFrame]
toucan_data_sdk/sdk.py
def write(self, dfs): """ Args: data (str | byte): Returns: dict: Dict[str, DataFrame] """ if not os.path.exists(self.EXTRACTION_CACHE_PATH): os.makedirs(self.EXTRACTION_CACHE_PATH) for name, df in dfs.items(): file_path =...
def write(self, dfs): """ Args: data (str | byte): Returns: dict: Dict[str, DataFrame] """ if not os.path.exists(self.EXTRACTION_CACHE_PATH): os.makedirs(self.EXTRACTION_CACHE_PATH) for name, df in dfs.items(): file_path =...
[ "Args", ":", "data", "(", "str", "|", "byte", ")", ":" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/sdk.py#L139-L153
[ "def", "write", "(", "self", ",", "dfs", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "EXTRACTION_CACHE_PATH", ")", ":", "os", ".", "makedirs", "(", "self", ".", "EXTRACTION_CACHE_PATH", ")", "for", "name", ",", "df", "i...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
clean_dataframe
This method is used to: - slugify the column names (if slugify is set to True) - convert columns to 'category' (if len(unique) < threshold) or 'int' - clean the dataframe and rename if necessary
toucan_data_sdk/utils/generic/clean.py
def clean_dataframe(df, is_slugify=True, threshold=50, rename_cols=None): """ This method is used to: - slugify the column names (if slugify is set to True) - convert columns to 'category' (if len(unique) < threshold) or 'int' - clean the dataframe and rename if necessary """ if is_slugify: ...
def clean_dataframe(df, is_slugify=True, threshold=50, rename_cols=None): """ This method is used to: - slugify the column names (if slugify is set to True) - convert columns to 'category' (if len(unique) < threshold) or 'int' - clean the dataframe and rename if necessary """ if is_slugify: ...
[ "This", "method", "is", "used", "to", ":", "-", "slugify", "the", "column", "names", "(", "if", "slugify", "is", "set", "to", "True", ")", "-", "convert", "columns", "to", "category", "(", "if", "len", "(", "unique", ")", "<", "threshold", ")", "or",...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/clean.py#L14-L33
[ "def", "clean_dataframe", "(", "df", ",", "is_slugify", "=", "True", ",", "threshold", "=", "50", ",", "rename_cols", "=", "None", ")", ":", "if", "is_slugify", ":", "df", "=", "df", ".", "rename", "(", "columns", "=", "slugify", ")", "df", "=", "df"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
compute_ffill_by_group
Compute `ffill` with `groupby` Dedicated method as there is a performance issue with a simple groupby/fillna (2017/07) The method `ffill` propagates last valid value forward to next values. --- ### Parameters *mandatory :* - `id_cols` (*list of str*): names of columns used to create each grou...
toucan_data_sdk/utils/generic/compute_ffill_by_group.py
def compute_ffill_by_group( df, id_cols: List[str], reference_cols: List[str], value_col: str ): """ Compute `ffill` with `groupby` Dedicated method as there is a performance issue with a simple groupby/fillna (2017/07) The method `ffill` propagates last valid value forwa...
def compute_ffill_by_group( df, id_cols: List[str], reference_cols: List[str], value_col: str ): """ Compute `ffill` with `groupby` Dedicated method as there is a performance issue with a simple groupby/fillna (2017/07) The method `ffill` propagates last valid value forwa...
[ "Compute", "ffill", "with", "groupby", "Dedicated", "method", "as", "there", "is", "a", "performance", "issue", "with", "a", "simple", "groupby", "/", "fillna", "(", "2017", "/", "07", ")", "The", "method", "ffill", "propagates", "last", "valid", "value", ...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_ffill_by_group.py#L6-L67
[ "def", "compute_ffill_by_group", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "reference_cols", ":", "List", "[", "str", "]", ",", "value_col", ":", "str", ")", ":", "check_params_columns_duplicate", "(", "id_cols", "+", "reference_cols", "+...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
fake_data_generator
`conf` is a list of dictionaries like {'type': 'label', 'values': ['Paris', 'Marseille', 'Lyons'], 'name': 'Cities'} and each dictionary will add a column. There are two different behaviours: - type: 'label' -> the new column will be taken into account for a cartesian product w...
toucan_data_sdk/fakir/fake_data_generator.py
def fake_data_generator(conf: List[dict]) -> pd.DataFrame: """ `conf` is a list of dictionaries like {'type': 'label', 'values': ['Paris', 'Marseille', 'Lyons'], 'name': 'Cities'} and each dictionary will add a column. There are two different behaviours: - type: 'label' -> the new column will...
def fake_data_generator(conf: List[dict]) -> pd.DataFrame: """ `conf` is a list of dictionaries like {'type': 'label', 'values': ['Paris', 'Marseille', 'Lyons'], 'name': 'Cities'} and each dictionary will add a column. There are two different behaviours: - type: 'label' -> the new column will...
[ "conf", "is", "a", "list", "of", "dictionaries", "like", "{", "type", ":", "label", "values", ":", "[", "Paris", "Marseille", "Lyons", "]", "name", ":", "Cities", "}", "and", "each", "dictionary", "will", "add", "a", "column", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/fakir/fake_data_generator.py#L8-L33
[ "def", "fake_data_generator", "(", "conf", ":", "List", "[", "dict", "]", ")", "->", "pd", ".", "DataFrame", ":", "# First create all the lines with the cartesian product of all the", "# possible values of 'label' columns", "label_confs", "=", "[", "x", "for", "x", "in"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
two_values_melt
Transforms one or multiple columns into rows. Unlike melt function, two value columns can be returned by the function (e.g. an evolution column and a price column) --- ### Parameters *mandatory :* - `first_value_vars` (*list of str*): name of the columns corresponding to the first returned va...
toucan_data_sdk/utils/generic/two_values_melt.py
def two_values_melt( df, first_value_vars: List[str], second_value_vars: List[str], var_name: str, value_name: str ): """ Transforms one or multiple columns into rows. Unlike melt function, two value columns can be returned by the function (e.g. an evolution column and a price column...
def two_values_melt( df, first_value_vars: List[str], second_value_vars: List[str], var_name: str, value_name: str ): """ Transforms one or multiple columns into rows. Unlike melt function, two value columns can be returned by the function (e.g. an evolution column and a price column...
[ "Transforms", "one", "or", "multiple", "columns", "into", "rows", ".", "Unlike", "melt", "function", "two", "value", "columns", "can", "be", "returned", "by", "the", "function", "(", "e", ".", "g", ".", "an", "evolution", "column", "and", "a", "price", "...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/two_values_melt.py#L5-L83
[ "def", "two_values_melt", "(", "df", ",", "first_value_vars", ":", "List", "[", "str", "]", ",", "second_value_vars", ":", "List", "[", "str", "]", ",", "var_name", ":", "str", ",", "value_name", ":", "str", ")", ":", "value_name_first", "=", "value_name",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
concat
Concatenate `columns` element-wise See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.cat.html) for more information --- ### Parameters *mandatory :* - `columns` (*list*): list of columns to concatenate (at least 2 columns) - `new_column` (*str*...
toucan_data_sdk/utils/postprocess/text.py
def concat( df, *, columns: List[str], new_column: str, sep: str = None ): """ Concatenate `columns` element-wise See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.cat.html) for more information --- ### Parame...
def concat( df, *, columns: List[str], new_column: str, sep: str = None ): """ Concatenate `columns` element-wise See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.cat.html) for more information --- ### Parame...
[ "Concatenate", "columns", "element", "-", "wise", "See", "[", "pandas", "doc", "]", "(", "https", ":", "//", "pandas", ".", "pydata", ".", "org", "/", "pandas", "-", "docs", "/", "stable", "/", "reference", "/", "api", "/", "pandas", ".", "Series", "...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/text.py#L452-L479
[ "def", "concat", "(", "df", ",", "*", ",", "columns", ":", "List", "[", "str", "]", ",", "new_column", ":", "str", ",", "sep", ":", "str", "=", "None", ")", ":", "if", "len", "(", "columns", ")", "<", "2", ":", "raise", "ValueError", "(", "'The...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
contains
Test if pattern or regex is contained within strings of `column` See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.contains.html) for more information --- ### Parameters *mandatory :* - `column` (*str*): the column - `pat` (*str*): character se...
toucan_data_sdk/utils/postprocess/text.py
def contains( df, column: str, *, pat: str, new_column: str = None, case: bool = True, na: Any = None, regex: bool = True ): """ Test if pattern or regex is contained within strings of `column` See [pandas doc]( https://pandas.pydata.org/pa...
def contains( df, column: str, *, pat: str, new_column: str = None, case: bool = True, na: Any = None, regex: bool = True ): """ Test if pattern or regex is contained within strings of `column` See [pandas doc]( https://pandas.pydata.org/pa...
[ "Test", "if", "pattern", "or", "regex", "is", "contained", "within", "strings", "of", "column", "See", "[", "pandas", "doc", "]", "(", "https", ":", "//", "pandas", ".", "pydata", ".", "org", "/", "pandas", "-", "docs", "/", "stable", "/", "reference",...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/text.py#L482-L513
[ "def", "contains", "(", "df", ",", "column", ":", "str", ",", "*", ",", "pat", ":", "str", ",", "new_column", ":", "str", "=", "None", ",", "case", ":", "bool", "=", "True", ",", "na", ":", "Any", "=", "None", ",", "regex", ":", "bool", "=", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
repeat
Duplicate each string in `column` by indicated number of time See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.repeat.html) for more information --- ### Parameters *mandatory :* - `column` (*str*): the column - `times` (*int*): times to repeat...
toucan_data_sdk/utils/postprocess/text.py
def repeat( df, column: str, *, times: int, new_column: str = None ): """ Duplicate each string in `column` by indicated number of time See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.repeat.html) for more information...
def repeat( df, column: str, *, times: int, new_column: str = None ): """ Duplicate each string in `column` by indicated number of time See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.repeat.html) for more information...
[ "Duplicate", "each", "string", "in", "column", "by", "indicated", "number", "of", "time", "See", "[", "pandas", "doc", "]", "(", "https", ":", "//", "pandas", ".", "pydata", ".", "org", "/", "pandas", "-", "docs", "/", "stable", "/", "reference", "/", ...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/text.py#L516-L541
[ "def", "repeat", "(", "df", ",", "column", ":", "str", ",", "*", ",", "times", ":", "int", ",", "new_column", ":", "str", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "column", "df", ".", "loc", "[", ":", ",", "new_column", "]", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
replace_pattern
Replace occurrences of pattern/regex in `column` with some other string See [pandas doc]( https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.str.replace.html) for more information --- ### Parameters *mandatory :* - `column` (*str*): the column - `pat` (*str*): charac...
toucan_data_sdk/utils/postprocess/text.py
def replace_pattern( df, column: str, *, pat: str, repl: str, new_column: str = None, case: bool = True, regex: bool = True ): """ Replace occurrences of pattern/regex in `column` with some other string See [pandas doc]( https://pandas.pyda...
def replace_pattern( df, column: str, *, pat: str, repl: str, new_column: str = None, case: bool = True, regex: bool = True ): """ Replace occurrences of pattern/regex in `column` with some other string See [pandas doc]( https://pandas.pyda...
[ "Replace", "occurrences", "of", "pattern", "/", "regex", "in", "column", "with", "some", "other", "string", "See", "[", "pandas", "doc", "]", "(", "https", ":", "//", "pandas", ".", "pydata", ".", "org", "/", "pandas", "-", "docs", "/", "stable", "/", ...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/text.py#L544-L575
[ "def", "replace_pattern", "(", "df", ",", "column", ":", "str", ",", "*", ",", "pat", ":", "str", ",", "repl", ":", "str", ",", "new_column", ":", "str", "=", "None", ",", "case", ":", "bool", "=", "True", ",", "regex", ":", "bool", "=", "True", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
catch
Decorator to catch an exception and don't raise it. Logs information if a decorator failed. Note: We don't want possible exceptions during logging to be raised. This is used to decorate any function that gets executed before or after the execution of the decorated function.
toucan_data_sdk/utils/decorators.py
def catch(logger): """ Decorator to catch an exception and don't raise it. Logs information if a decorator failed. Note: We don't want possible exceptions during logging to be raised. This is used to decorate any function that gets executed before or after the execution of the d...
def catch(logger): """ Decorator to catch an exception and don't raise it. Logs information if a decorator failed. Note: We don't want possible exceptions during logging to be raised. This is used to decorate any function that gets executed before or after the execution of the d...
[ "Decorator", "to", "catch", "an", "exception", "and", "don", "t", "raise", "it", ".", "Logs", "information", "if", "a", "decorator", "failed", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L61-L80
[ "def", "catch", "(", "logger", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "func", "(", "*", "args", ",", "*",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
log_message
Decorator to log a message before executing a function
toucan_data_sdk/utils/decorators.py
def log_message(logger, message=""): """ Decorator to log a message before executing a function """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): _log_message(logger, func.__name__, message) result = func(*args, **kwargs) return resul...
def log_message(logger, message=""): """ Decorator to log a message before executing a function """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): _log_message(logger, func.__name__, message) result = func(*args, **kwargs) return resul...
[ "Decorator", "to", "log", "a", "message", "before", "executing", "a", "function" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L109-L120
[ "def", "log_message", "(", "logger", ",", "message", "=", "\"\"", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_log_message", "(", "logg...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
log_time
Decorator to log the execution time of a function
toucan_data_sdk/utils/decorators.py
def log_time(logger): """ Decorator to log the execution time of a function """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): start = time.time() result = func(*args, **kwargs) end = time.time() _log_time(logger, func.__na...
def log_time(logger): """ Decorator to log the execution time of a function """ def decorator(func): @wraps(func) def wrapper(*args, **kwargs): start = time.time() result = func(*args, **kwargs) end = time.time() _log_time(logger, func.__na...
[ "Decorator", "to", "log", "the", "execution", "time", "of", "a", "function" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L123-L136
[ "def", "log_time", "(", "logger", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "start", "=", "time", ".", "time", "(", ")", "result", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
log_shapes
Decorator to log the shapes of input and output dataframes It considers all the dataframes passed either as arguments or keyword arguments as inputs and all the dataframes returned as outputs.
toucan_data_sdk/utils/decorators.py
def log_shapes(logger): """ Decorator to log the shapes of input and output dataframes It considers all the dataframes passed either as arguments or keyword arguments as inputs and all the dataframes returned as outputs. """ def decorator(func): @wraps(func) def wrapper(*args, *...
def log_shapes(logger): """ Decorator to log the shapes of input and output dataframes It considers all the dataframes passed either as arguments or keyword arguments as inputs and all the dataframes returned as outputs. """ def decorator(func): @wraps(func) def wrapper(*args, *...
[ "Decorator", "to", "log", "the", "shapes", "of", "input", "and", "output", "dataframes" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L139-L155
[ "def", "log_shapes", "(", "logger", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "input_shapes", "=", "_get_dfs_shapes", "(", "*", "args", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
log
Basic log decorator Can be used as : - @log (with default logger) - @log(mylogger) - @log(start_message='Hello !", logger=mylogger, end_message='Bye !')
toucan_data_sdk/utils/decorators.py
def log(logger=None, start_message='Starting...', end_message='Done...'): """ Basic log decorator Can be used as : - @log (with default logger) - @log(mylogger) - @log(start_message='Hello !", logger=mylogger, end_message='Bye !') """ def actual_log(f, real_logger=logger): logger...
def log(logger=None, start_message='Starting...', end_message='Done...'): """ Basic log decorator Can be used as : - @log (with default logger) - @log(mylogger) - @log(start_message='Hello !", logger=mylogger, end_message='Bye !') """ def actual_log(f, real_logger=logger): logger...
[ "Basic", "log", "decorator", "Can", "be", "used", "as", ":", "-" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L158-L182
[ "def", "log", "(", "logger", "=", "None", ",", "start_message", "=", "'Starting...'", ",", "end_message", "=", "'Done...'", ")", ":", "def", "actual_log", "(", "f", ",", "real_logger", "=", "logger", ")", ":", "logger", "=", "real_logger", "or", "_logger",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
domain
Allow to apply a function f(df: DataFrame) -> DataFrame) on dfs by specifying the key E.g instead of writing: def process_domain1(dfs): df = dfs['domain1'] # actual process dfs['domain1'] = df return dfs You can write: @domain('domain1') d...
toucan_data_sdk/utils/decorators.py
def domain(domain_name): """ Allow to apply a function f(df: DataFrame) -> DataFrame) on dfs by specifying the key E.g instead of writing: def process_domain1(dfs): df = dfs['domain1'] # actual process dfs['domain1'] = df return dfs You can write:...
def domain(domain_name): """ Allow to apply a function f(df: DataFrame) -> DataFrame) on dfs by specifying the key E.g instead of writing: def process_domain1(dfs): df = dfs['domain1'] # actual process dfs['domain1'] = df return dfs You can write:...
[ "Allow", "to", "apply", "a", "function", "f", "(", "df", ":", "DataFrame", ")", "-", ">", "DataFrame", ")", "on", "dfs", "by", "specifying", "the", "key", "E", ".", "g", "instead", "of", "writing", ":", "def", "process_domain1", "(", "dfs", ")", ":",...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L185-L213
[ "def", "domain", "(", "domain_name", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dfs", ",", "", "*", "args", "=", "args", "if", "no...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
cache
Avoid to recompute a function if its parameters and its source code doesnt have changed. Args: requires: list of dependencies (functions or function names) disabled (bool): disable the cache mecanism for this function (useful if you only want to use the ...
toucan_data_sdk/utils/decorators.py
def cache( # noqa: C901 requires=None, disabled=False, applied_on_method=False, check_param=True, limit=None ): """ Avoid to recompute a function if its parameters and its source code doesnt have changed. Args: requires: list of dependencies (functions or function names) ...
def cache( # noqa: C901 requires=None, disabled=False, applied_on_method=False, check_param=True, limit=None ): """ Avoid to recompute a function if its parameters and its source code doesnt have changed. Args: requires: list of dependencies (functions or function names) ...
[ "Avoid", "to", "recompute", "a", "function", "if", "its", "parameters", "and", "its", "source", "code", "doesnt", "have", "changed", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L219-L341
[ "def", "cache", "(", "# noqa: C901", "requires", "=", "None", ",", "disabled", "=", "False", ",", "applied_on_method", "=", "False", ",", "check_param", "=", "True", ",", "limit", "=", "None", ")", ":", "if", "not", "requires", ":", "requires", "=", "[",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
setup_cachedir
This function injects a joblib.Memory object in the cache() function (in a thread-specific slot of its 'memories' attribute).
toucan_data_sdk/utils/decorators.py
def setup_cachedir(cachedir, mmap_mode=None, bytes_limit=None): """ This function injects a joblib.Memory object in the cache() function (in a thread-specific slot of its 'memories' attribute). """ if not hasattr(cache, 'memories'): cache.memories = {} memory = joblib.Memory( locati...
def setup_cachedir(cachedir, mmap_mode=None, bytes_limit=None): """ This function injects a joblib.Memory object in the cache() function (in a thread-specific slot of its 'memories' attribute). """ if not hasattr(cache, 'memories'): cache.memories = {} memory = joblib.Memory( locati...
[ "This", "function", "injects", "a", "joblib", ".", "Memory", "object", "in", "the", "cache", "()", "function", "(", "in", "a", "thread", "-", "specific", "slot", "of", "its", "memories", "attribute", ")", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/decorators.py#L347-L360
[ "def", "setup_cachedir", "(", "cachedir", ",", "mmap_mode", "=", "None", ",", "bytes_limit", "=", "None", ")", ":", "if", "not", "hasattr", "(", "cache", ",", "'memories'", ")", ":", "cache", ".", "memories", "=", "{", "}", "memory", "=", "joblib", "."...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
melt
A melt will transform a dataset by creating a column "variable" and a column "value". This function is useful to transform a dataset into a format where one or more columns are identifier variables, while all other columns, considered measured variables (value_vars), are “unpivoted” to the row axis, leaving...
toucan_data_sdk/utils/postprocess/melt.py
def melt( df, id: List[str], value: List[str], dropna=False ): """ A melt will transform a dataset by creating a column "variable" and a column "value". This function is useful to transform a dataset into a format where one or more columns are identifier variables, while ...
def melt( df, id: List[str], value: List[str], dropna=False ): """ A melt will transform a dataset by creating a column "variable" and a column "value". This function is useful to transform a dataset into a format where one or more columns are identifier variables, while ...
[ "A", "melt", "will", "transform", "a", "dataset", "by", "creating", "a", "column", "variable", "and", "a", "column", "value", ".", "This", "function", "is", "useful", "to", "transform", "a", "dataset", "into", "a", "format", "where", "one", "or", "more", ...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/melt.py#L6-L59
[ "def", "melt", "(", "df", ",", "id", ":", "List", "[", "str", "]", ",", "value", ":", "List", "[", "str", "]", ",", "dropna", "=", "False", ")", ":", "df", "=", "df", "[", "(", "id", "+", "value", ")", "]", "df", "=", "pd", ".", "melt", "...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
rename
Replaces data values and column names according to the locale --- ### Parameters - `values` (optional: dict): - key: term to be replaced - value: - key: the locale e.g. 'en' or 'fr' - value: term's translation - `columns` (optional: dict): - key: column...
toucan_data_sdk/utils/postprocess/rename.py
def rename( df, values: Dict[str, Dict[str, str]] = None, columns: Dict[str, Dict[str, str]] = None, locale: str = None ): """ Replaces data values and column names according to the locale --- ### Parameters - `values` (optional: dict): - key: term to be re...
def rename( df, values: Dict[str, Dict[str, str]] = None, columns: Dict[str, Dict[str, str]] = None, locale: str = None ): """ Replaces data values and column names according to the locale --- ### Parameters - `values` (optional: dict): - key: term to be re...
[ "Replaces", "data", "values", "and", "column", "names", "according", "to", "the", "locale" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/rename.py#L4-L70
[ "def", "rename", "(", "df", ",", "values", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ",", "columns", ":", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "str", "]", "]", "=", "None", ",", "locale"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
compute_cumsum
Compute cumsum for a group of columns. --- ### Parameters *mandatory :* - `id_cols` (*list*): the columns id to create each group - `reference_cols` (*list*): the columns to order the cumsum - `value_cols` (*list*): the columns to cumsum *optional :* - `new_value_cols` (*list*): the ...
toucan_data_sdk/utils/generic/compute_cumsum.py
def compute_cumsum( df, id_cols: List[str], reference_cols: List[str], value_cols: List[str], new_value_cols: List[str] = None, cols_to_keep: List[str] = None ): """ Compute cumsum for a group of columns. --- ### Parameters *mandatory :* - `id_cols` (*list*): the colum...
def compute_cumsum( df, id_cols: List[str], reference_cols: List[str], value_cols: List[str], new_value_cols: List[str] = None, cols_to_keep: List[str] = None ): """ Compute cumsum for a group of columns. --- ### Parameters *mandatory :* - `id_cols` (*list*): the colum...
[ "Compute", "cumsum", "for", "a", "group", "of", "columns", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_cumsum.py#L9-L80
[ "def", "compute_cumsum", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "reference_cols", ":", "List", "[", "str", "]", ",", "value_cols", ":", "List", "[", "str", "]", ",", "new_value_cols", ":", "List", "[", "str", "]", "=", "None", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
combine_columns_aggregation
Aggregates data to reproduce "All" category for requester --- ### Parameters *mandatory :* - `id_cols` (*list*): the columns id to group - `cols_for_combination` (*dict*): colums corresponding to the filters as key and their default value as value *optional :* - `agg_func` (*str*,...
toucan_data_sdk/utils/generic/combine_columns_aggregation.py
def combine_columns_aggregation( df, id_cols: List[str], cols_for_combination: Dict[str, str], agg_func: Union[str, List[str], Dict[str, str]] = 'sum' ): """ Aggregates data to reproduce "All" category for requester --- ### Parameters *mandatory :* - `id_cols` ...
def combine_columns_aggregation( df, id_cols: List[str], cols_for_combination: Dict[str, str], agg_func: Union[str, List[str], Dict[str, str]] = 'sum' ): """ Aggregates data to reproduce "All" category for requester --- ### Parameters *mandatory :* - `id_cols` ...
[ "Aggregates", "data", "to", "reproduce", "All", "category", "for", "requester" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/combine_columns_aggregation.py#L7-L43
[ "def", "combine_columns_aggregation", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "cols_for_combination", ":", "Dict", "[", "str", ",", "str", "]", ",", "agg_func", ":", "Union", "[", "str", ",", "List", "[", "str", "]", ",", "Dict", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
get_param_value_from_func_call
Get the value of a function's parameter based on its signature and the call's args and kwargs. Example: >>> def foo(a, b, c=3, d=4): ... pass ... >>> # what would be the value of "c" when calling foo(1, b=2, c=33) ? >>> get_param_value_from_func_call('c', foo, [1], {'...
toucan_data_sdk/utils/helpers.py
def get_param_value_from_func_call(param_name, func, call_args, call_kwargs): """ Get the value of a function's parameter based on its signature and the call's args and kwargs. Example: >>> def foo(a, b, c=3, d=4): ... pass ... >>> # what would be the value of "c" whe...
def get_param_value_from_func_call(param_name, func, call_args, call_kwargs): """ Get the value of a function's parameter based on its signature and the call's args and kwargs. Example: >>> def foo(a, b, c=3, d=4): ... pass ... >>> # what would be the value of "c" whe...
[ "Get", "the", "value", "of", "a", "function", "s", "parameter", "based", "on", "its", "signature", "and", "the", "call", "s", "args", "and", "kwargs", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L25-L45
[ "def", "get_param_value_from_func_call", "(", "param_name", ",", "func", ",", "call_args", ",", "call_kwargs", ")", ":", "signature", "=", "inspect", ".", "signature", "(", "func", ")", "params_list", "=", "signature", ".", "parameters", ".", "keys", "(", ")",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
get_func_sourcecode
Try to get sourcecode using standard inspect.getsource(). If the function comes from a module which has been created dynamically (not from the filesystem), then it tries to read the sourcecode on the filesystem anyway. WARNING: can do weird things if the filesystem code slightly differs from ...
toucan_data_sdk/utils/helpers.py
def get_func_sourcecode(func): """ Try to get sourcecode using standard inspect.getsource(). If the function comes from a module which has been created dynamically (not from the filesystem), then it tries to read the sourcecode on the filesystem anyway. WARNING: can do weird things if the filesy...
def get_func_sourcecode(func): """ Try to get sourcecode using standard inspect.getsource(). If the function comes from a module which has been created dynamically (not from the filesystem), then it tries to read the sourcecode on the filesystem anyway. WARNING: can do weird things if the filesy...
[ "Try", "to", "get", "sourcecode", "using", "standard", "inspect", ".", "getsource", "()", ".", "If", "the", "function", "comes", "from", "a", "module", "which", "has", "been", "created", "dynamically", "(", "not", "from", "the", "filesystem", ")", "then", ...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L48-L86
[ "def", "get_func_sourcecode", "(", "func", ")", ":", "def", "getsource", "(", "func", ")", ":", "lines", ",", "lnum", "=", "getsourcelines", "(", "func", ")", "return", "''", ".", "join", "(", "lines", ")", "def", "getsourcelines", "(", "func", ")", ":...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
slugify
Returns a slugified name (we allow _ to be used)
toucan_data_sdk/utils/helpers.py
def slugify(name, separator='-'): """Returns a slugified name (we allow _ to be used)""" return _slugify(name, regex_pattern=re.compile('[^-_a-z0-9]+'), separator=separator)
def slugify(name, separator='-'): """Returns a slugified name (we allow _ to be used)""" return _slugify(name, regex_pattern=re.compile('[^-_a-z0-9]+'), separator=separator)
[ "Returns", "a", "slugified", "name", "(", "we", "allow", "_", "to", "be", "used", ")" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L99-L101
[ "def", "slugify", "(", "name", ",", "separator", "=", "'-'", ")", ":", "return", "_slugify", "(", "name", ",", "regex_pattern", "=", "re", ".", "compile", "(", "'[^-_a-z0-9]+'", ")", ",", "separator", "=", "separator", ")" ]
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
resolve_dependencies
Given a function name and a mapping of function dependencies, returns a list of *all* the dependencies for this function.
toucan_data_sdk/utils/helpers.py
def resolve_dependencies(func_name, dependencies): """ Given a function name and a mapping of function dependencies, returns a list of *all* the dependencies for this function. """ def _resolve_deps(func_name, func_deps): """ Append dependencies recursively to func_deps (accumulator) """ ...
def resolve_dependencies(func_name, dependencies): """ Given a function name and a mapping of function dependencies, returns a list of *all* the dependencies for this function. """ def _resolve_deps(func_name, func_deps): """ Append dependencies recursively to func_deps (accumulator) """ ...
[ "Given", "a", "function", "name", "and", "a", "mapping", "of", "function", "dependencies", "returns", "a", "list", "of", "*", "all", "*", "the", "dependencies", "for", "this", "function", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L104-L119
[ "def", "resolve_dependencies", "(", "func_name", ",", "dependencies", ")", ":", "def", "_resolve_deps", "(", "func_name", ",", "func_deps", ")", ":", "\"\"\" Append dependencies recursively to func_deps (accumulator) \"\"\"", "if", "func_name", "in", "func_deps", ":", "re...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
clean_cachedir_old_entries
Remove old entries from the cache
toucan_data_sdk/utils/helpers.py
def clean_cachedir_old_entries(cachedir: StoreBackendBase, func_name: str, limit: int) -> int: """Remove old entries from the cache""" if limit < 1: raise ValueError("'limit' must be greater or equal to 1") cache_entries = get_cachedir_entries(cachedir, func_name) cache_entries = sorted(cache_e...
def clean_cachedir_old_entries(cachedir: StoreBackendBase, func_name: str, limit: int) -> int: """Remove old entries from the cache""" if limit < 1: raise ValueError("'limit' must be greater or equal to 1") cache_entries = get_cachedir_entries(cachedir, func_name) cache_entries = sorted(cache_e...
[ "Remove", "old", "entries", "from", "the", "cache" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/helpers.py#L122-L133
[ "def", "clean_cachedir_old_entries", "(", "cachedir", ":", "StoreBackendBase", ",", "func_name", ":", "str", ",", "limit", ":", "int", ")", "->", "int", ":", "if", "limit", "<", "1", ":", "raise", "ValueError", "(", "\"'limit' must be greater or equal to 1\"", "...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
roll_up
Creates aggregates following a given hierarchy --- ### Parameters *mandatory :* - `levels` (*list of str*): name of the columns composing the hierarchy (from the top to the bottom level). - `groupby_vars` (*list of str*): name of the columns with value to aggregate. - `extra_groupby_cols` (*l...
toucan_data_sdk/utils/generic/roll_up.py
def roll_up( df, levels: List[str], groupby_vars: List[str], extra_groupby_cols: List[str] = None, var_name: str = 'type', value_name: str = 'value', agg_func: str = 'sum', drop_levels: List[str] = None ): """ Creates aggregates following a given h...
def roll_up( df, levels: List[str], groupby_vars: List[str], extra_groupby_cols: List[str] = None, var_name: str = 'type', value_name: str = 'value', agg_func: str = 'sum', drop_levels: List[str] = None ): """ Creates aggregates following a given h...
[ "Creates", "aggregates", "following", "a", "given", "hierarchy" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/roll_up.py#L5-L88
[ "def", "roll_up", "(", "df", ",", "levels", ":", "List", "[", "str", "]", ",", "groupby_vars", ":", "List", "[", "str", "]", ",", "extra_groupby_cols", ":", "List", "[", "str", "]", "=", "None", ",", "var_name", ":", "str", "=", "'type'", ",", "val...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
argmax
Keep the row of the data corresponding to the maximal value in a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column containing the value you want to keep the maximum *optional :* - `groups` (*str or list(str)*): name of the column(s) used for 'groupby' logic (...
toucan_data_sdk/utils/postprocess/argmax.py
def argmax(df, column: str, groups: Union[str, List[str]] = None): """ Keep the row of the data corresponding to the maximal value in a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column containing the value you want to keep the maximum *optional :* - `gro...
def argmax(df, column: str, groups: Union[str, List[str]] = None): """ Keep the row of the data corresponding to the maximal value in a column --- ### Parameters *mandatory :* - `column` (*str*): name of the column containing the value you want to keep the maximum *optional :* - `gro...
[ "Keep", "the", "row", "of", "the", "data", "corresponding", "to", "the", "maximal", "value", "in", "a", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/argmax.py#L4-L51
[ "def", "argmax", "(", "df", ",", "column", ":", "str", ",", "groups", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ")", ":", "if", "groups", "is", "None", ":", "df", "=", "df", "[", "df", "[", "column", "]", "==",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
argmin
Keep the row of the data corresponding to the minimal value in a column --- ### Parameters *mandatory :* - `column` (str): name of the column containing the value you want to keep the minimum *optional :* - `groups` (*str or list(str)*): name of the column(s) used for 'groupby' logic (th...
toucan_data_sdk/utils/postprocess/argmax.py
def argmin(df, column: str, groups: Union[str, List[str]] = None): """ Keep the row of the data corresponding to the minimal value in a column --- ### Parameters *mandatory :* - `column` (str): name of the column containing the value you want to keep the minimum *optional :* - `group...
def argmin(df, column: str, groups: Union[str, List[str]] = None): """ Keep the row of the data corresponding to the minimal value in a column --- ### Parameters *mandatory :* - `column` (str): name of the column containing the value you want to keep the minimum *optional :* - `group...
[ "Keep", "the", "row", "of", "the", "data", "corresponding", "to", "the", "minimal", "value", "in", "a", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/argmax.py#L54-L101
[ "def", "argmin", "(", "df", ",", "column", ":", "str", ",", "groups", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ")", ":", "if", "groups", "is", "None", ":", "df", "=", "df", "[", "df", "[", "column", "]", "==",...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
fillna
Can fill NaN values from a column with a given value or a column --- ### Parameters - `column` (*str*): name of column you want to fill - `value`: NaN will be replaced by this value - `column_value`: NaN will be replaced by value from this column *NOTE*: You must set either the 'value' param...
toucan_data_sdk/utils/postprocess/fillna.py
def fillna(df, column: str, value=None, column_value=None): """ Can fill NaN values from a column with a given value or a column --- ### Parameters - `column` (*str*): name of column you want to fill - `value`: NaN will be replaced by this value - `column_value`: NaN will be replaced by ...
def fillna(df, column: str, value=None, column_value=None): """ Can fill NaN values from a column with a given value or a column --- ### Parameters - `column` (*str*): name of column you want to fill - `value`: NaN will be replaced by this value - `column_value`: NaN will be replaced by ...
[ "Can", "fill", "NaN", "values", "from", "a", "column", "with", "a", "given", "value", "or", "a", "column" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/fillna.py#L4-L58
[ "def", "fillna", "(", "df", ",", "column", ":", "str", ",", "value", "=", "None", ",", "column_value", "=", "None", ")", ":", "if", "column", "not", "in", "df", ".", "columns", ":", "df", "[", "column", "]", "=", "nan", "if", "value", "is", "not"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
date_requester_generator
From a dataset containing dates in a column, return a dataset with at least 3 columns : - "DATE" : Label of date - "DATETIME" : Date in datetime dtype - "GRANULARITY" : Granularity of date --- ### Parameters *mandatory :* - `date_column` (*str*): name of column containing the date in ...
toucan_data_sdk/utils/generic/date_requester.py
def date_requester_generator( df: pd.DataFrame, date_column: str, frequency: str, date_column_format: str = None, format: str = '%Y-%m-%d', granularities: Dict[str, str] = None, others_format: Dict[str, str] = None, times_delta: Dict[str, str] = None ) -> ...
def date_requester_generator( df: pd.DataFrame, date_column: str, frequency: str, date_column_format: str = None, format: str = '%Y-%m-%d', granularities: Dict[str, str] = None, others_format: Dict[str, str] = None, times_delta: Dict[str, str] = None ) -> ...
[ "From", "a", "dataset", "containing", "dates", "in", "a", "column", "return", "a", "dataset", "with", "at", "least", "3", "columns", ":", "-", "DATE", ":", "Label", "of", "date", "-", "DATETIME", ":", "Date", "in", "datetime", "dtype", "-", "GRANULARITY"...
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/date_requester.py#L5-L118
[ "def", "date_requester_generator", "(", "df", ":", "pd", ".", "DataFrame", ",", "date_column", ":", "str", ",", "frequency", ":", "str", ",", "date_column_format", ":", "str", "=", "None", ",", "format", ":", "str", "=", "'%Y-%m-%d'", ",", "granularities", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
_norm_date
normalize symbolic date values (e.g. 'TODAY') Convert a symbolic value in a valid date. Currenlty known symbolic values are 'TODAY', 'YESTERDAY' and 'TOMORROW'. NOTE: This function will return `date` (not `datetime`) instances. Parameters: `datestr`: the date to parse, formatted as `date_fmt`...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def _norm_date(datestr: str, date_fmt: str) -> date: """normalize symbolic date values (e.g. 'TODAY') Convert a symbolic value in a valid date. Currenlty known symbolic values are 'TODAY', 'YESTERDAY' and 'TOMORROW'. NOTE: This function will return `date` (not `datetime`) instances. Parameters: ...
def _norm_date(datestr: str, date_fmt: str) -> date: """normalize symbolic date values (e.g. 'TODAY') Convert a symbolic value in a valid date. Currenlty known symbolic values are 'TODAY', 'YESTERDAY' and 'TOMORROW'. NOTE: This function will return `date` (not `datetime`) instances. Parameters: ...
[ "normalize", "symbolic", "date", "values", "(", "e", ".", "g", ".", "TODAY", ")" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L13-L34
[ "def", "_norm_date", "(", "datestr", ":", "str", ",", "date_fmt", ":", "str", ")", "->", "date", ":", "try", ":", "days", "=", "{", "'TODAY'", ":", "0", ",", "'YESTERDAY'", ":", "-", "1", ",", "'TOMORROW'", ":", "1", "}", "[", "datestr", ".", "up...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
add_offset
add a human readable offset to `dateobj` and return corresponding date. rely on `pandas.Timedelta` and add the following extra shortcuts: - "w", "week" and "weeks" for a week (i.e. 7days) - "month', "months" for a month (i.e. no day computation, just increment the month) - "y", "year', "years" for a ye...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def add_offset(dateobj, hr_offset: str, sign: str): """add a human readable offset to `dateobj` and return corresponding date. rely on `pandas.Timedelta` and add the following extra shortcuts: - "w", "week" and "weeks" for a week (i.e. 7days) - "month', "months" for a month (i.e. no day computation, ju...
def add_offset(dateobj, hr_offset: str, sign: str): """add a human readable offset to `dateobj` and return corresponding date. rely on `pandas.Timedelta` and add the following extra shortcuts: - "w", "week" and "weeks" for a week (i.e. 7days) - "month', "months" for a month (i.e. no day computation, ju...
[ "add", "a", "human", "readable", "offset", "to", "dateobj", "and", "return", "corresponding", "date", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L37-L65
[ "def", "add_offset", "(", "dateobj", ",", "hr_offset", ":", "str", ",", "sign", ":", "str", ")", ":", "sign_coeff", "=", "1", "if", "sign", "==", "'+'", "else", "-", "1", "try", ":", "return", "dateobj", "+", "sign_coeff", "*", "pd", ".", "Timedelta"...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
add_months
return `dateobj` + `nb_months` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_months(date(2018, 1, 1), 1) datetime.date(2018, 1, 1) >>> add_months(date(2018, 1, 1), -1) datetime.date(2017, 12, 1) >>> add_months(date(2018, 1, 1), 25) ...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def add_months(dateobj, nb_months: int): """return `dateobj` + `nb_months` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_months(date(2018, 1, 1), 1) datetime.date(2018, 1, 1) >>> add_months(date(2018, 1, 1), -1) datetime.date(2017, 1...
def add_months(dateobj, nb_months: int): """return `dateobj` + `nb_months` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_months(date(2018, 1, 1), 1) datetime.date(2018, 1, 1) >>> add_months(date(2018, 1, 1), -1) datetime.date(2017, 1...
[ "return", "dateobj", "+", "nb_months" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L68-L92
[ "def", "add_months", "(", "dateobj", ",", "nb_months", ":", "int", ")", ":", "nb_years", ",", "nb_months", "=", "divmod", "(", "nb_months", ",", "12", ")", "month", "=", "dateobj", ".", "month", "+", "nb_months", "if", "month", ">", "12", ":", "nb_year...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
add_years
return `dateobj` + `nb_years` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_years(date(2018, 1, 1), 1) datetime.date(2019, 1, 1) >>> add_years(date(2018, 1, 1), -1) datetime.date(2017, 1, 1) >>> add_years(date(2020, 2, 29), 1) da...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def add_years(dateobj, nb_years): """return `dateobj` + `nb_years` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_years(date(2018, 1, 1), 1) datetime.date(2019, 1, 1) >>> add_years(date(2018, 1, 1), -1) datetime.date(2017, 1, 1) >...
def add_years(dateobj, nb_years): """return `dateobj` + `nb_years` If landing date doesn't exist (e.g. february, 30th), return the last day of the landing month. >>> add_years(date(2018, 1, 1), 1) datetime.date(2019, 1, 1) >>> add_years(date(2018, 1, 1), -1) datetime.date(2017, 1, 1) >...
[ "return", "dateobj", "+", "nb_years" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L95-L112
[ "def", "add_years", "(", "dateobj", ",", "nb_years", ")", ":", "year", "=", "dateobj", ".", "year", "+", "nb_years", "lastday", "=", "monthrange", "(", "year", ",", "dateobj", ".", "month", ")", "[", "1", "]", "return", "dateobj", ".", "replace", "(", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
parse_date
parse `datestr` and return corresponding date object. `datestr` should be a string matching `date_fmt` and parseable by `strptime` but some offset can also be added using `(datestr) + OFFSET` or `(datestr) - OFFSET` syntax. When using this syntax, `OFFSET` should be understable by `pandas.Timedelta` (c...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def parse_date(datestr: str, date_fmt: str) -> date: """parse `datestr` and return corresponding date object. `datestr` should be a string matching `date_fmt` and parseable by `strptime` but some offset can also be added using `(datestr) + OFFSET` or `(datestr) - OFFSET` syntax. When using this syntax,...
def parse_date(datestr: str, date_fmt: str) -> date: """parse `datestr` and return corresponding date object. `datestr` should be a string matching `date_fmt` and parseable by `strptime` but some offset can also be added using `(datestr) + OFFSET` or `(datestr) - OFFSET` syntax. When using this syntax,...
[ "parse", "datestr", "and", "return", "corresponding", "date", "object", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L115-L152
[ "def", "parse_date", "(", "datestr", ":", "str", ",", "date_fmt", ":", "str", ")", "->", "date", ":", "rgx", "=", "re", ".", "compile", "(", "r'\\((?P<date>.*)\\)(\\s*(?P<sign>[+-])(?P<offset>.*))?$'", ")", "datestr", "=", "datestr", ".", "strip", "(", ")", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
filter_by_date
Filter dataframe your data by date. This function will interpret `start`, `stop` and `atdate` and build the corresponding date range. The caller must specify either: - `atdate`: keep all rows matching this date exactly, - `start`: keep all rows matching this date onwards. - `stop`: keep all rows m...
toucan_data_sdk/utils/postprocess/filter_by_date.py
def filter_by_date( df, date_col: str, date_format: str = '%Y-%m-%d', start: str = None, stop: str = None, atdate: str = None ): """ Filter dataframe your data by date. This function will interpret `start`, `stop` and `atdate` and build the corresponding date range. The caller m...
def filter_by_date( df, date_col: str, date_format: str = '%Y-%m-%d', start: str = None, stop: str = None, atdate: str = None ): """ Filter dataframe your data by date. This function will interpret `start`, `stop` and `atdate` and build the corresponding date range. The caller m...
[ "Filter", "dataframe", "your", "data", "by", "date", "." ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/filter_by_date.py#L155-L220
[ "def", "filter_by_date", "(", "df", ",", "date_col", ":", "str", ",", "date_format", ":", "str", "=", "'%Y-%m-%d'", ",", "start", ":", "str", "=", "None", ",", "stop", ":", "str", "=", "None", ",", "atdate", ":", "str", "=", "None", ")", ":", "mask...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
replace
Change the label of a value or a columns within your data source. (Similar to `rename` but does not have the notion of locale) --- ### Parameters *mandatory :* - `column` (*str*): name of the column to modify. - `to_replace` (*dict*): keys of this dict are old values pointing on substitute. ...
toucan_data_sdk/utils/postprocess/replace.py
def replace(df, column: str, new_column: str = None, **kwargs): """ Change the label of a value or a columns within your data source. (Similar to `rename` but does not have the notion of locale) --- ### Parameters *mandatory :* - `column` (*str*): name of the column to modify. - `to_r...
def replace(df, column: str, new_column: str = None, **kwargs): """ Change the label of a value or a columns within your data source. (Similar to `rename` but does not have the notion of locale) --- ### Parameters *mandatory :* - `column` (*str*): name of the column to modify. - `to_r...
[ "Change", "the", "label", "of", "a", "value", "or", "a", "columns", "within", "your", "data", "source", ".", "(", "Similar", "to", "rename", "but", "does", "not", "have", "the", "notion", "of", "locale", ")" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/replace.py#L1-L56
[ "def", "replace", "(", "df", ",", "column", ":", "str", ",", "new_column", ":", "str", "=", "None", ",", "*", "*", "kwargs", ")", ":", "new_column", "=", "new_column", "or", "column", "df", ".", "loc", "[", ":", ",", "new_column", "]", "=", "df", ...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
percentage
Add a column to the dataframe according to the groupby logic on group_cols --- ### Parameters *mandatory :* - `column` (*str*): name of the desired column you need percentage on *optional :* - `group_cols` (*list*): names of columns for the groupby logic - `new_column` (*str*): name of t...
toucan_data_sdk/utils/postprocess/percentage.py
def percentage( df, column: str, group_cols: Union[str, List[str]] = None, new_column: str = None ): """ Add a column to the dataframe according to the groupby logic on group_cols --- ### Parameters *mandatory :* - `column` (*str*): name of the desired column y...
def percentage( df, column: str, group_cols: Union[str, List[str]] = None, new_column: str = None ): """ Add a column to the dataframe according to the groupby logic on group_cols --- ### Parameters *mandatory :* - `column` (*str*): name of the desired column y...
[ "Add", "a", "column", "to", "the", "dataframe", "according", "to", "the", "groupby", "logic", "on", "group_cols" ]
ToucanToco/toucan-data-sdk
python
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/postprocess/percentage.py#L4-L64
[ "def", "percentage", "(", "df", ",", "column", ":", "str", ",", "group_cols", ":", "Union", "[", "str", ",", "List", "[", "str", "]", "]", "=", "None", ",", "new_column", ":", "str", "=", "None", ")", ":", "new_column", "=", "new_column", "or", "co...
c3ca874e1b64f4bdcc2edda750a72d45d1561d8a
test
ada_family_core
Optimize by SGD, AdaGrad, or AdaDelta.
deepy/trainers/cores/ada_family.py
def ada_family_core(params, gparams, learning_rate = 0.01, eps= 1e-6, rho=0.95, method="ADADELTA", beta=0.0, gsum_regularization = 0.0001): """ Optimize by SGD, AdaGrad, or AdaDelta. """ _, _, _, args = inspect.getargvalues(inspect.currentframe()) logging.info("ada_family_co...
def ada_family_core(params, gparams, learning_rate = 0.01, eps= 1e-6, rho=0.95, method="ADADELTA", beta=0.0, gsum_regularization = 0.0001): """ Optimize by SGD, AdaGrad, or AdaDelta. """ _, _, _, args = inspect.getargvalues(inspect.currentframe()) logging.info("ada_family_co...
[ "Optimize", "by", "SGD", "AdaGrad", "or", "AdaDelta", "." ]
zomux/deepy
python
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/deepy/trainers/cores/ada_family.py#L13-L61
[ "def", "ada_family_core", "(", "params", ",", "gparams", ",", "learning_rate", "=", "0.01", ",", "eps", "=", "1e-6", ",", "rho", "=", "0.95", ",", "method", "=", "\"ADADELTA\"", ",", "beta", "=", "0.0", ",", "gsum_regularization", "=", "0.0001", ")", ":"...
090fbad22a08a809b12951cd0d4984f5bd432698