towhee.functional.mixins.list.ListMixin¶
- class towhee.functional.mixins.list.ListMixin[source]¶
Bases:
object
Mixin to make dc an extension of python list.
Methods
Append item to data collection.
Clear a DataCollection.
Copy a DataCollection.
Count an element in DataCollection.
Extend a DataCollection.
Insert data into a DataCollection.
Extend a DataCollection.
Remove element from DataCollection.
Reverse a DataCollection.
Sort a DataCollection.
- append(*args) DataCollection [source]¶
Append item to data collection.
- Parameters:
item (Any) – the item to append
- Returns:
self
- Return type:
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([0, 1, 2]) >>> dc.append(3).append(4) [0, 1, 2, 3, 4]
- clear(*args) DataCollection [source]¶
Clear a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.clear() []
- copy(*args) DataCollection [source]¶
Copy a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc_1 = dc.copy() >>> dc_1._iterable.append(4) >>> dc, dc_1 ([1, 2, 3], [1, 2, 3, 4])
- count(*args) int [source]¶
Count an element in DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.count(1) 1
- extend(*args) DataCollection [source]¶
Extend a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.extend([4, 5]) [1, 2, 3, 4, 5]
- insert(*args) DataCollection [source]¶
Insert data into a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.insert(0, 0) [0, 1, 2, 3]
- pop(*args) DataCollection [source]¶
Extend a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.pop() [1, 2]
- remove(*args) DataCollection [source]¶
Remove element from DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.remove(1) [2, 3]
- reverse(*args) DataCollection [source]¶
Reverse a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 2, 3]) >>> dc.reverse() [3, 2, 1]
- sort(*args) DataCollection [source]¶
Sort a DataCollection.
Examples:
>>> from towhee import DataCollection >>> dc = DataCollection([1, 4, 3]) >>> dc.sort() [1, 3, 4]