Data Documentation¶
This document specifies python-duplicate’s data package.
FromList¶
-
class
pyduplicate.data.from_list.
FromList
(lst: list, key: str = None)¶ Handle search of duplicate or unique item inside a list
- Parameters
lst (list) – Param to work on
key (str) – Param to work in a list of dict if you need it
-
analyze
(analyze_type: str, feedback: bool = True) → dict¶ Analyze the list to get the items and their indexes (depending on the analyze_type)
- Parameters
analyze_type (str) – Param to determine what type of analyse to do
feedback (bool) – Param to return more or less information
- Returns
without feedback:
{ "all_index": [REVERSED_ORDER_INDEX(ES)] }
with feedback:
{ "all_index": [REVERSED_ORDER_INDEX(ES)], "VALUE_X": [INDEX(ES)], "VALUE_Y": [INDEX(ES)], }
-
create_unique
() → list¶ - Returns
Unique items (by deleting duplicate items)
-
get_duplicate
() → list¶ - Returns
Only all duplicate items
-
get_unique
() → list¶ - Returns
Only unique items
Utils¶
-
class
pyduplicate.data.utils.
Utils
(lst: list)¶ Provides functions to handle search of duplicate or unique item inside a list
- Parameters
lst (list) – Param to work on. By default its the same list passed to FromList
-
create_list
(key: str) → None¶ Create a list of all item for a given key
- Parameters
key (str) – Dict key on which to get data
-
create_unique_index
(feedback: bool = False) → dict¶ Identify duplicated item and return the index of each of them except for the first one (in order to create a list of unique item)
- Parameters
feedback (bool) – Param to return more or less information
- Returns
without feedback:
{ "all_index": [REVERSED_ORDER_INDEX(ES)] }
with feedback:
{ "all_index": [REVERSED_ORDER_INDEX(ES)], "VALUE_X": [INDEX(ES)], "VALUE_Y": [INDEX(ES)], }
-
create_update_feedback
(index: int, value: any, feedback: bool) → None¶ Create or update the ‘self.indexes’ dict to provide feedback
-
get_indexes
(index_type: str, feedback: bool = False) → dict¶ Identify unique or duplicate item and return the index of each of them
- Parameters
index_type (str) – Param to know what type of item index we want
feedback (bool) – Param to return more or less information
- Returns
without feedback:
{ "all_index": [INDEX(ES)] }
with feedback:
{ "all_index": [INDEX(ES)], "VALUE_X": [INDEX(ES)], "VALUE_Y": [INDEX(ES)], }
-
get_type
() → None¶ Get the type of the first item which is not None
-
validate_items
() → None¶ Check if all items are of the same type
- Raises
TypeError – If items are NOT of the same type