Data Objects#
- class yankee.data.attrdict.AttrDict[source]#
-
- clear() None. Remove all items from D.#
- copy() a shallow copy of D#
- fromkeys(value=None, /)#
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)#
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items#
- keys() a set-like object providing a view on D's keys#
- pop(k[, d]) v, remove specified key and return the corresponding value.#
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem()#
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)#
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- to_dict(item_class=<class 'dict'>, collection_class=<class 'list'>, date_style='python')#
Convert object to simple Python dictionary
- to_json(*args, **kwargs)#
Convert object to a JSON string
- to_mongo()#
Convert object to a Python dictionary with datetime.dates converted to datetime.datetimes for MongoDB compatibility
- to_pandas()#
Convert object to Pandas Series
- update([E, ]**F) None. Update D from dict/iterable E and F.#
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values#
- class yankee.data.collection.ListCollection(iterable=(), /)[source]#
- append(object, /)#
Append object to the end of the list.
- clear()#
Remove all items from list.
- copy()#
Return a shallow copy of the list.
- count(value, /)#
Return number of occurrences of value.
- explode(attribute, unpack=False, connector='.', prefix=True)#
Implement an “explode” function for nested listed objects.
- extend(iterable, /)#
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)#
Insert object before index.
- pop(index=-1, /)#
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)#
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()#
Reverse IN PLACE.
- sort(*, key=None, reverse=False)#
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- to_list()#
Return a list of item objects from the Collection
- to_mongo()#
Return a list of dictionaries containing MongoDB compatible datatypes
- to_pandas(annotate=[])#
Convert Collection into a Pandas DataFrame
- to_records(item_class=<class 'dict'>, collection_class=<class 'list'>)#
Return a list of dictionaries containing item data in ordinary Python types Useful for ingesting into NoSQL databases
- unpack(attribute, connector='.', prefix=True)#
Implement an “unpack” function for nested single objects
- values(*fields, **kw_fields)#
Return a Collection that will return a Row object for each item with a subset of attributes positional arguments will result in Row objects where the fields match the field names on the item, keyword arguments can be used to rename attributes. When passed as key=field, the resulting dictionary will have key: item[field]
- values_list(*fields, flat=False, **kw_fields)#
Return a Collection that will return tuples for each item with a subset of attributes. If only a single field is passed, the keyword argument “flat” can be passed to return a simple list