<jupyter_start><jupyter_text>select the unique elements from an array<jupyter_code>arr = np.array([1,1,2,2,3,3,4,5,6])
print(np.unique(arr))
# return the number of times each unique item appears
arr = np.array([1,1,2,2,3,3,4,5,6])
uniques, counts = np.unique(arr, return_counts=True)
print(uniques)
print(counts)<jupyter_output>[1 2 3 4 5 6]
[2 2 2 1 1 1]<jupyter_text>compute the intersection & union of two arrays<jupyter_code>arr1 = np.array([1,2,3,4,5])
arr2 = np.array([3,4,5,6,7])
# intersection
print(np.intersect1d(arr1, arr2))
# union
print(np.union1d(arr1, arr2))<jupyter_output>[1 2 3 4 5 6 7]<jupyter_text>compute whether each element of an array is contained in another<jupyter_code>print(np.in1d(arr1, arr2))
# preserve the shape of the array in the output, if the array is of higher dimensions
print(np.isin(arr1, arr2))<jupyter_output>[False False  True  True  True]<jupyter_text>compute the elements in an array that are not in another<jupyter_code>print(np.setdiff1d(arr1, arr2))<jupyter_output>[1 2]<jupyter_text>compute the elements in either of two arrays, but not both<jupyter_code>print(np.setxor1d(arr1, arr2))<jupyter_output>[1 2 6 7]
{'fraction_non_alphanumeric': 0.13028472821397757, 'fraction_numerical': 0.062122519413287315, 'mean_word_length': 7.169014084507042, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '287039', 'license': 'MIT', 'n_tokens_mistral': 489, 'n_tokens_neox': 460, 'n_words': 117, 'path': '9, Set Operations.ipynb', 'repo_name': 'therealhaseeb/Numpy-Tutorial', 'size': '1159'}