With this command we can see the array's [shape]({{ page.root }}/reference/#shape):

With the following command, we can see the array's [shape]({{ page.root }}/reference/#shape):

~~~

print(data.shape)

...

...

@@ -301,19 +302,19 @@ print(data.shape)

~~~

{: .output}

This tells us that `data`has 60 rows and 40 columns. When we created the

variable `data` to store our arthritis data, we didn't just create the array, we also

The output tells us that the `data` array variable contains 60 rows and 40 columns. When we created the

variable `data` to store our arthritis data, we didn't just create the array; we also

created information about the array, called [members]({{ page.root }}/reference/#member) or

attributes. This extra information describes `data` in

the same way an adjective describes a noun.

`data.shape` is an attribute of `data` which describes the dimensions of `data`.

`data.shape` is an attribute of `data` which describes the dimensions of `data`.

We use the same dotted notation for the attributes of variables

that we use for the functions in libraries

because they have the same part-and-whole relationship.

If we want to get a single number from the array,

we must provide an [index]({{ page.root }}/reference/#index) in square brackets,

just as we do in math when referring to an element of a matrix. Our inflammation data has two dimensions, so we will need to use two indices to refer to a value:

we must provide an [index]({{ page.root }}/reference/#index) in square brackets after the variable name,

just as we do in math when referring to an element of a matrix. Our inflammation data has two dimensions, so we will need to use two indices to refer to one specific value:

~~~

print('first value in data:', data[0, 0])

...

...

@@ -337,7 +338,7 @@ middle value in data: 13.0

The expression `data[30, 20]` accesses the element at row 30, column 20. While this expression may not surprise you,

`data[0, 0]` might.

Programming languages like Fortran, MATLAB and R start counting at 1,

Programming languages like Fortran, MATLAB and R start counting at 1

because that's what human beings have done for thousands of years.

Languages in the C family (including C++, Java, Perl, and Python) count from 0

because it represents an offset from the first value in the array (the second

...

...

@@ -360,7 +361,7 @@ the index is how many steps we have to take from the start to get the item we wa

> What may also surprise you is that when Python displays an array,

> it shows the element with index `[0, 0]` in the upper left corner

> rather than the lower left.

> This is consistent with the way mathematicians draw matrices,

> This is consistent with the way mathematicians draw matrices

> but different from the Cartesian coordinates.

> The indices are (row, column) instead of (column, row) for the same reason,

> which can be confusing when plotting data.

...

...

@@ -422,6 +423,7 @@ print('small is:')

print(small)

~~~

{: .language-python}

The above example selects rows 0 through 2 and columns 36 through to the end of the array.

~~~

small is:

...

...

@@ -433,9 +435,9 @@ small is:

Arrays also know how to perform common mathematical operations on their values.

The simplest operations with data are arithmetic:

add, subtract, multiply, and divide.

addition, subtraction, multiplication, and division.

When you do such operations on arrays,

the operation is done on each individual element of the array.

the operation is done element-by-element.

Thus:

~~~

...

...

@@ -444,7 +446,7 @@ doubledata = data * 2.0

{: .language-python}

will create a new array `doubledata`

whose elements have the value of two times the value of the corresponding elements in `data`:

each elements of which is twice the value of the corresponding element in `data`:

~~~

print('original:')

...

...

@@ -467,7 +469,7 @@ doubledata:

{: .output}

If,

instead of taking an array and doing arithmetic with a single value (as above)

instead of taking an array and doing arithmetic with a single value (as above),

you did the arithmetic operation with another array of the same shape,

the operation will be done on corresponding elements of the two arrays.

Thus:

...

...

@@ -494,8 +496,8 @@ tripledata:

~~~

{: .output}

Often, we want to do more than add, subtract, multiply, and divide values of data.

NumPy knows how to do more complex operations on arrays.

Often, we want to do more than add, subtract, multiply, and divide array elements.

NumPy knows how to do more complex operations, too.

If we want to find the average inflammation for all patients on all days,

for example,

we can ask NumPy to compute `data`'s mean value:

...

...

@@ -512,8 +514,6 @@ print(numpy.mean(data))

`mean` is a [function]({{ page.root }}/reference/#function) that takes

an array as an [argument]({{ page.root }}/reference/#argument).