<jupyter_start><jupyter_text>Scalar operations<jupyter_code>import dask.array as da
my_arr = da.random.randint(10, size=20, chunks=3)
my_arr.compute()
my_hundred_arr = my_arr + 100
my_hundred_arr.compute()
(my_arr * (-1)).compute()<jupyter_output><empty_output><jupyter_text>Reductions<jupyter_code>dask_sum = my_arr.sum()
dask_sum
my_arr.compute()
dask_sum.compute()
my_ones_arr = da.ones((10,10), chunks=2, dtype=int)
my_ones_arr.compute()
my_ones_arr.mean(axis=0).compute()
my_custom_array = da.random.randint(10, size=(4,4), chunks=(1,4))
my_custom_array.compute()
my_custom_array.mean(axis=0).compute()
my_custom_array.mean(axis=1).compute()<jupyter_output><empty_output><jupyter_text>Slicing<jupyter_code>my_custom_array[1:3, 2:4]
my_custom_array[1:3, 2:4].compute()<jupyter_output><empty_output><jupyter_text>Broadcasting<jupyter_code>my_custom_array.compute()
my_small_arr = da.ones(4, chunks=2)
my_small_arr.compute()
brd_example1 = da.add(my_custom_array, my_small_arr)
# [[7, 1, 4, 4], + [[1, 1, 1, 1]
#  [1, 5, 5, 5],   [1, 1, 1, 1]
#  [9, 0, 2, 8],   [1, 1, 1, 1]
#  [1, 8, 8, 0]]   [1, 1, 1, 1]]
brd_example1.compute()
ten_arr = da.full_like(my_small_arr, 10)
ten_arr.compute()
brd_example2 = da.add(my_custom_array, ten_arr)
brd_example2.compute()<jupyter_output><empty_output><jupyter_text>Reshaping<jupyter_code>my_custom_array.shape
custom_arr_1d = my_custom_array.reshape(16)
custom_arr_1d
custom_arr_1d.compute()<jupyter_output><empty_output><jupyter_text>Stacking<jupyter_code>stacked_arr = da.stack([brd_example1, brd_example2])
stacked_arr.compute()
another_stacked = da.stack([brd_example1, brd_example2], axis=1)
another_stacked.compute()<jupyter_output><empty_output><jupyter_text>Concatenate<jupyter_code>concate_arr = da.concatenate([brd_example1, brd_example2])
concate_arr.compute()
another_concate_arr = da.concatenate([brd_example1, brd_example2],axis=1)
another_concate_arr.compute()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15467625899280577, 'fraction_numerical': 0.044193216855087356, 'mean_word_length': 10.125714285714286, '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': '9607', 'license': 'MIT', 'n_tokens_mistral': 891, 'n_tokens_neox': 846, 'n_words': 103, 'path': 'Section 2/Digging Deeper into Dask Arrays.ipynb', 'repo_name': 'akashmavle5/-Scalable-Data-Analysis-in-Python-with-Dask', 'size': '1946'}