<jupyter_start><jupyter_text>We have already seen how to build a Numpy array from a sequence of values.<jupyter_code># Load the Numpy package, and rename to "np"
import numpy as np<jupyter_output><empty_output><jupyter_text>One way to create an array is to make a sequence of values, such as a list, and pass these to the `np.array` function, like this:<jupyter_code>my_list = [1.1, 2.2, 3.2, 2.1]
my_array = np.array(my_list)
my_array<jupyter_output><empty_output><jupyter_text>Here we create the full 4 value array in one call to `np.array`.Another way make an array is to build it up one value at a time.To do this, I can start with an empty array, like this:<jupyter_code>an_empty_list = []
a = np.array(an_empty_list)
a<jupyter_output><empty_output><jupyter_text>Now imagine I want to build up the same array as I did above.  I can *append* each value to the array, using the `np.append` function.As usual, you can check what the `np.append` function does by making a new cell in the notebook, and typing `np.append?` followed by Enter.  This will show you the help for `np.append`.You will find that `np.append` needs (at least) two *arguments*, which are:1. The array to append to, called `arr` in the documentation and2. The stuff to append, called `values` in the documentation.Here we append a single number:<jupyter_code>a = np.append(a, 1.1)
a
a = np.append(a, 2.2)
a
a = np.append(a, 3.2)
a
a = np.append(a, 2.1)
a<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09608785175017158, 'fraction_numerical': 0.013040494166094716, 'mean_word_length': 4.879032258064516, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '474753', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 506, 'n_tokens_neox': 495, 'n_words': 206, 'path': 'notebooks/03/numpy_append.ipynb', 'repo_name': 'matthew-brett/cfd-uob', 'size': '1457'}