riptable.rt_itemcontainer
Classes
Container for items in Struct -- all values are tuples with an attribute |
- class riptable.rt_itemcontainer.ItemContainer(*args, **kwds)
Container for items in Struct – all values are tuples with an attribute
- __contains__(*args)
- __delitem__(key)
ic.__delitem__(y) <==> del ic[y]
- __eq__(other)
Return self==value.
- __getitem__(key)
- __iter__()
- __len__()
- __ne__(other)
Return self!=value.
- __next__()
- __repr__()
ic.__repr__() <==> repr(ic)
- __setitem__(key, value)
ic.__setitem__(i, y) <==> ic[i]=y
- _get_move_cols(cols)
Possibly convert list/array/dictionary/string/index of items to move for item_move_to_front(), item_move_to_back()
- _set_attribute(item, name, value)
- _tagged_as_dict(attrname)
Returns dictionary of columns tagged with attrname.
- _tagged_get_dict_max(attrname)
Returns unordered dictionary of columns tagged with attrname, max value for order.
- _tagged_get_names(attrname)
Returns a list of item names tagged with attrname in order.
- _tagged_remove(attrname)
Removes existing items tagged with attrname.
- _tagged_set_names(listnames, attrname)
Removes existing items tagged with attrname. If items in listnames exist, they will be tagged with attrname.
- apply(func, *args, cols=None)
Performs a possibly inplace operation on items in the itemcontainer
- clear()
- copy(cols=None, deep=False)
Returns a shallow copy of the item container. cols list can be provided for specific selection.
- copy_apply(func, *args, cols=None)
Returns a copy of the itemcontainer, applying a function to items before swapping them out in the new ItemContainer object. Used in Dataset row masking.
- copy_inplace(selector)
inplace row-selector (mask, fancy-index, or slice) applied
- get_dict_values()
Returns a tuple of items in the item dict. Each item is a list.
- item_add_prefix(prefix)
inplace operation. adds prefix in front of existing item name
faster than calling rename
- item_add_suffix(suffix)
inplace operation. adds suffix in front of existing item name
faster than calling rename
- item_delete(key)
- item_exists(item)
- item_get_attribute(key, attrib_name, default=None)
Retrieve the value of the attribute previously assigned with
item_set_attribute
.- Parameters:
key – name of the item
attrib_name – name of the attribute
- item_get_dict()
return the underlying dict
values are stored in the first tuple, attributes in the second tuple
- item_get_len()
- item_get_value(key)
return the value for the given key
NOTE: a good spot to put a counter for debugging
- item_get_values(keylist)
return list of value for the given key used for fast dataset slicing/copy with column selection
- item_move_to_back(cols)
Move single column or group of columns to front of list for iteration/indexing/display. Values of columns will remain unchanged.
- Parameters:
cols – list of column names to move.
- Returns:
None
- item_move_to_front(cols)
Move single column or group of columns to front of list for iteration/indexing/display. Values of columns will remain unchanged.
- Parameters:
cols – list of column names to move.
- Returns:
None
- item_rename(old, new)
Rename a single column.
- Parameters:
old – Current column name.
new – New column name.
- Returns:
value portion of item that was renamed
- item_replace_all(newdict, check_exists=True)
Replace the data for each item in the item dict. Original attributes will be retained.
- Parameters:
newdict (dictionary of item names -> new item data (can also be a dataset)) –
check_exists (if True, all newdict keys and old item keys will be compared to ensure a match) –
- item_set_attribute(key, attrib_name, attrib_value)
Attach an attribute (name,value) pair to the item.
Any valid dictionary name and any object can be assigned.
Note: see
item_get_attribute
to retrieve.- Parameters:
key – name of the item
attrib_name – name of the attribute
attrib_value – value of the attribute
- item_set_value(key, value, attr=None)
- item_set_value_internal(key, value)
- item_str_match(expression, flags=0)
Create a boolean mask vector for items whose names match the regex. NB Uses re.match(), not re.search().
- Parameters:
expression – regular expression
flags – regex flags (from re module).
- Returns:
list array of bools (len ncols) which is true for columns which match the regex.
- item_str_replace(old, new, maxr=-1)
- Parameters:
old – string to look for within individual names of columns
new – string to replace old string in column names
If an item name contains the old string, the old string will be replaced with the new one. If replacing the string conflicts with an existing item name, an error will be raised.
returns True if column names were replaced
- items()
- items_as_dict()
Return dictionary of items without attributes.
- items_tolist()
- iter_values()
This will yield the full values in _items dict (lists with item, attribute)
- keys()
- label_as_dict()
- label_get_names()
- label_remove()
- label_set_names(listnames)
- pop(*args)
- setdefault(*args)
- summary_as_dict()
- summary_get_names()
- summary_remove()
- summary_set_names(listnames)
- update(*args)
- values()