<jupyter_start><jupyter_text>Numpy Basics Challenge<jupyter_code># To import numpy:
import numpy as np  # np is de-facto standard convention<jupyter_output><empty_output><jupyter_text>Brief Recap on Numpy ArraysNumPy's main object is the **homogeneous** ***multidimensional array***. It is a table of elements (usually numbers), all of the same type. In Numpy dimensions are called **axes**. The number of axes is called **rank**. The most important attributes of an ndarray object are:* **ndarray.ndim**     - the number of axes (dimensions) of the array. * **ndarray.shape**    - the dimensions of the array. For a matrix with n rows and m columns, shape will be (n,m). * **ndarray.size**     - the total number of elements of the array. * **ndarray.dtype**    - numpy.int32, numpy.int16, and numpy.float64 are some examples. * **ndarray.itemsize** - the size in bytes of elements of the array. For example, elements of type float64 has itemsize 8 (=64/8)   Warm Up: Creating `numpy` arraysThere are a number of ways to initialize new numpy arrays, for example from a Python list or tuples!<jupyter_code>np.array([1, 2, 3, 4])<jupyter_output><empty_output><jupyter_text>Ex 1. Create an array containing integers from $2$ to $2^6$ Hint: use Python `range` function  1.1 Print `ndarray` attributes and properties(e.g. `type`, `dtype`, `shape...`) using previous on  Ex 2. Create a 3x3 Matrix array and fill it with integer numbers  Ex3: Create a Matrix of any size and fill it with random numbers HInt: take a look at `numpy.random.rand`  1. Using _array-generating_ functionsFor larger arrays it is inpractical to initialize the data manually, using explicit python lists. Instead we can use one of the many **functions** in `numpy` that generates arrays of different forms. So far, you should already have used one that is `numpy.random.rand`.Some of the most common are: * `np.arange`; * `np.linspace`; * `np.logspace`; * `np.ones`;* `np.zeros`;The following challenges will require you to use one (or many) of these functions.  Ex 1.1Create an array of floating-point numbers in an arbitrary range (randomly generated), and using a decimal step (e.g. `0.2`) **Note**: You CAN use **three** numpy functions in this exercise. Guess the difference!.  Ex 1.2Create an Matrix of any shape full of zeros  Ex 1.3Create an array of ones and put as the main diagonal of a matrix  Hint: Take a look at `np.diag` and `np.eye`  Ex 1.4Create an arbitrary array of numbers and put it as the first upper off-diagonal of a new matrix Hint: Look at the parameters of  `np.diag`  2. File I/O Comma-separated values (CSV)A very common file format for data files are the comma-separated values (CSV), or related format such as TSV (tab-separated values). To read data from such file into Numpy arrays we can use the `numpy.genfromtxt` function. For example:<jupyter_code>!head files/stockholm_td_adj.dat<jupyter_output>1800  1  1    -6.1    -6.1    -6.1 1
1800  1  2   -15.4   -15.4   -15.4 1
1800  1  3   -15.0   -15.0   -15.0 1
1800  1  4   -19.3   -19.3   -19.3 1
1800  1  5   -16.8   -16.8   -16.8 1
1800  1  6   -11.4   -11.4   -11.4 1
1800  1  7    -7.6    -7.6    -7.6 1
1800  1  8    -7.1    -7.1    -7.1 1
1800  1  9   -10.1   -10.1   -10.1 1
1800  1 10    -9.5    -9.5    -9.5 1
{'fraction_non_alphanumeric': 0.0993276283618582, 'fraction_numerical': 0.05715158924205379, 'mean_word_length': 3.3581890812250332, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '124689', 'license': 'MIT', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1057, 'n_words': 485, 'path': '1_apprentice/1.5. Numpy Challenge.ipynb', 'repo_name': 'leriomaggio/develer-data-science', 'size': '3272'}