from pandas.core.base import FrozenList
Type: type
String form: <class 'pandas.core.base.FrozenList'>
File: /site-packages/pandas/core/base.py
Docstring:
Container that doesn't allow setting item *but*
because it's technically non-hashable, will be used
for lookups, appropriately, etc.
Why not just use tuple? What extra functionality would a FrozenList offer?
tuples are immutable lists , frozensets are immutable sets . frozensets aren't indexed, but you have the functionality of sets - O(1) element lookups, and functionality such as unions and intersections. They also can't contain duplicates, like their mutable counterparts.
FrozenList is a list-like structure which implements collections. abc. MutableSequence. The list is mutable until FrozenList.
Internally, tuples are stored a little more efficiently than lists, and also tuples can be accessed slightly faster.
Python frozenset() Frozen set is just an immutable version of a Python set object. While elements of a set can be modified at any time, elements of the frozen set remain the same after creation. Due to this, frozen sets can be used as keys in Dictionary or as elements of another set.
This is an internal pandas construct. Not using tuple because:
The construct is used to represent a MultiIndex levels,labels, and names. The point of it is to prevent modification of these thru attributes and force the use of methods (e.g. set_levels()
). As the state of these cannot be changed independent (for level/labels), but must be changed together.
These are 'public' properties though, so it needed an access mechanism that could do all of this (and yet still be changed internally if necessary, for performance reasons).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With