You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Words are useful, but what’s more useful are the sentences and stories we build with them. Similarly, while a lot of powerful, general tools are built into languages like Python, specialized tools built up from these basic units live in <ahref="reference.html#library">libraries</a> that can be called upon when needed.</p>
48
-
<p>In order to load our inflammation data, we need to <ahref="reference.html#import">import</a> a library called <ahref="http://docs.scipy.org/doc/numpy/" title="NumPy Documentation">NumPy</a>. In general you should use this library if you want to do fancy things with numbers, especially if you have matrices or arrays. We can load NumPy using:</p>
48
+
<p>In order to load our inflammation data, we need to access (<ahref="reference.html#import">import</a>in Python terminology) a library called <ahref="http://docs.scipy.org/doc/numpy/" title="NumPy Documentation">NumPy</a>. In general you should use this library if you want to do fancy things with numbers, especially if you have matrices or arrays. We can import NumPy using:</p>
<p>Importing a library is like getting a piece of lab equipment out of a storage locker and setting it up on the bench. Libraries provide additional functionality to the basic Python package, much like a new piece of equipment adds functionality to a lab space. Once you’ve loaded the library, we can ask the library to read our data file for us:</p>
50
+
<p>Importing a library is like getting a piece of lab equipment out of a storage locker and setting it up on the bench. Libraries provide additional functionality to the basic Python package, much like a new piece of equipment adds functionality to a lab space. Once you’ve imported the library, we can ask the library to read our data file for us:</p>
<p>Now that our data is in memory, we can start doing things with it. First, let’s ask what <ahref="reference.html#type">type</a> of thing <code>data</code> refers to:</p>
<p>The output tells us that <code>data</code> currently refers to an N-dimensional array created by the NumPy library. These data correspond to arthritis patients’ inflammation. The rows are the individual patients and the columns are their daily inflammation measurements. We can see what the array’s <ahref="reference.html#shape">shape</a> is like this:</p>
125
+
<p>The output tells us that <code>data</code> currently refers to an N-dimensional array created by the NumPy library. These data correspond to arthritis patients’ inflammation. The rows are the individual patients and the columns are their daily inflammation measurements.</p>
<p>A Numpy array contains one or more elements of the same type. <code>type</code> will only tell you that a variable is a NumPy array. We can also find the out the type of the data contained in the NumPy array.</p>
<p>This tells us that <code>data</code> has 60 rows and 40 columns. When we created the variable <code>data</code> to store our arthritis data, we didn’t just create the array, we also created information about the array, called <ahref="reference.html#member">members</a> or attributes. This extra information describes <code>data</code> in the same way an adjective describes a noun. <code>data.shape</code> is an attribute of <code>data</code> which describes the dimensions of <code>data</code>. 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.</p>
0 commit comments