<jupyter_start><jupyter_text>Table of Contents1&nbsp;&nbsp;Sets2&nbsp;&nbsp;Initialization3&nbsp;&nbsp;Built-in Functions3.1&nbsp;&nbsp;union( )3.2&nbsp;&nbsp;add( )3.3&nbsp;&nbsp;intersection( )3.4&nbsp;&nbsp;difference( )3.5&nbsp;&nbsp;symmetric_difference( )3.6&nbsp;&nbsp;issubset( )3.7&nbsp;&nbsp;isdisjoint( )3.8&nbsp;&nbsp;issuperset( )3.9&nbsp;&nbsp;pop( )3.10&nbsp;&nbsp;remove( )3.11&nbsp;&nbsp;clear( )  SetsSets are used to perform some standard set operations.Sets are mainly used to eliminate repeated numbers in a sequence/list.   InitializationSets are declared as `set()` which will initialize a empty set.<jupyter_code>set1 = set()
print(type(set1))<jupyter_output><class 'set'><jupyter_text>Also `set([sequence])` can be executed to declare a set with elements.<jupyter_code>set0 = set([1,2,2,3,3,4])
print(set0)<jupyter_output>{1, 2, 3, 4}<jupyter_text>**NOTE:** Elements 2,3 which are repeated twice are seen only once. Thus in a set each element is distinct.  Built-in Functions<jupyter_code>set1 = set([1,2,3])
set2 = set([2,3,4,5])<jupyter_output><empty_output><jupyter_text>union( )Function returns a set which contains all the elements of both the sets without repetition.<jupyter_code>set1.union(set2)<jupyter_output><empty_output><jupyter_text>add( )Will add a particular element into the set. Note that the index of the newly added element is arbitrary and can be placed anywhere not necessarily in the end.<jupyter_code>set1.add(0)
set1<jupyter_output><empty_output><jupyter_text>intersection( )function outputs a set which contains all the elements that are in both sets.<jupyter_code>set1.intersection(set2)<jupyter_output><empty_output><jupyter_text>difference( )function outputs a set which contains elements that are in set1 and not in set2.<jupyter_code>set1.difference(set2)<jupyter_output><empty_output><jupyter_text>symmetric_difference( )function outputs a set which contains elements that are in one of the sets.<jupyter_code>set2.symmetric_difference(set1)<jupyter_output><empty_output><jupyter_text>issubset( )Is used to check that the set1 is a subset of set2 respectively.<jupyter_code>set1.issubset(set2)
set1.issubset({0,1,2,3,4})<jupyter_output><empty_output><jupyter_text>isdisjoint( )is used to check if the set1 is a disjoint of set2 respectively.<jupyter_code>set2.isdisjoint(set1)
set1.isdisjoint({4,5})<jupyter_output><empty_output><jupyter_text>issuperset( )is used to check if the set1 is a superset of set2.<jupyter_code>set2.issuperset(set1)
set1.issuperset(set2)
set1.issuperset({0})<jupyter_output><empty_output><jupyter_text>pop( )is used to remove an arbitrary element in the set<jupyter_code>set1.pop()
print(set1)<jupyter_output>{1, 2, 3}<jupyter_text>remove( )function deletes the specified element from the set.<jupyter_code>set1.remove(2)
set1<jupyter_output><empty_output><jupyter_text>clear( )is used to clear all the elements and make that set an empty set.<jupyter_code>set1.clear()
set1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12048192771084337, 'fraction_numerical': 0.03346720214190094, 'mean_word_length': 8.73615635179153, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '563063', 'license': 'MIT', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1064, 'n_words': 252, 'path': '01_PythonWorkshop/Day02/06_Sets.ipynb', 'repo_name': 'erkundanec/Data-Science-Full', 'size': '2988'}