<jupyter_start><jupyter_text>Combining Data<jupyter_code>data1 = np.random.randint(5,15,size=(5,3))
data2 = np.random.randint(5,15,size=(5,3))
np.hstack([data1,data2]).shape
np.vstack([data1, data2]).shape
np.concatenate([data1, data2], axis=1).shape
np.stack([data1, data2], axis=2).shape<jupyter_output><empty_output><jupyter_text>Save and load data<jupyter_code>x = np.linspace(0,5,100)
y = np.sin(x)
y.shape
np.savetxt('x.txt',x)
np.savetxt('data.txt',np.c_[x,y])
x = np.loadtxt('data.txt')
x.shape
# !cat x.txt
x = np.random.normal(0,1,(1000,1000))
np.savetxt('x.txt',x,)
np.save('xdata',x)
x = np.load('xdata.npy')
x.shape
x = np.random.normal(0,1,(100,100))
y = np.random.normal(0,1,(100,100))
z = np.random.normal(0,1,(100,100))
np.savez('dataset',d1=x,d2=y,d3=z)
data = np.load('dataset.npz')
data.files
x = data['d1']
y = data['d2']
z = data['d3']
x = np.diag([1,2])
y = np.ones((2,2))
x
y
x*y
np.dot(x,y)
x = np.random.normal(0,1,[5,5])
np.linalg.inv(x)
np.linalg.eigvals(x).astype(np.complex64)
x = np.array([1,1,2])
pdf, ebin = np.histogram(x,2)
cbin = 0.5*(ebin[1:]+ebin[:-1])

pdf,cbin<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.24513274336283186, 'fraction_numerical': 0.0752212389380531, 'mean_word_length': 6.54, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '359773', 'license': 'MIT', 'n_tokens_mistral': 594, 'n_tokens_neox': 565, 'n_words': 71, 'path': 'SI/2-numpy.ipynb', 'repo_name': 'vafaei-ar/alzahra-workshop-2019', 'size': '1130'}