<jupyter_start><jupyter_text>Set routines<jupyter_code>import numpy as np
np.__version__
author = 'kyubyong. <EMAIL>'<jupyter_output><empty_output><jupyter_text>Making proper sets Q1. Get unique elements and reconstruction indices from x. And reconstruct x.<jupyter_code>x = np.array([1, 2, 6, 4, 2, 3, 2])


x = np.array([1, 2, 6, 4, 2, 3, 2])
a,b = np.unique(x,return_inverse=True)
print(a)
print(b)
print(a[b])<jupyter_output>[1 2 3 4 6]
[0 1 4 3 1 2 1]
[1 2 6 4 2 3 2]<jupyter_text>Boolean operations Q2. Create a boolean array of the same shape as x. If each element of x is present in y, the result will be True, otherwise False.<jupyter_code>x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1])

x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1])

np.in1d(x,y)<jupyter_output><empty_output><jupyter_text>Q3. Find the unique intersection of x and y.<jupyter_code>x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])

np.intersect1d(x,y)<jupyter_output><empty_output><jupyter_text>Q4. Find the unique elements of x that are not present in y.<jupyter_code>x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])

x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])
np.setdiff1d(x,y)<jupyter_output><empty_output><jupyter_text>Q5. Find the xor elements of x and y.<jupyter_code>x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])

x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])
np.setxor1d(x,y)<jupyter_output><empty_output><jupyter_text>Q6. Find the union of x and y.<jupyter_code>x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])

x = np.array([0, 1, 2, 5, 0])
y = np.array([0, 1, 4])
np.union1d(x,y)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1845780206435944, 'fraction_numerical': 0.0692167577413479, 'mean_word_length': 4.802816901408451, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '623537', 'license': 'MIT', 'n_tokens_mistral': 832, 'n_tokens_neox': 739, 'n_words': 212, 'path': '11_Set_routines.ipynb', 'repo_name': 'kis0403/numpy_exercises', 'size': '1660'}