Skip to main content
Engineering LibreTexts

8: Arrays in Python (1 of 2)

  • Page ID
    39389
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)

    There are several candidates in the Python language for representing the type of array structure we introduced in chapter 7. One is the plain-ol’ Python list, which you may have used if you’ve taken a computer science course in Python. Turns out, lists are going to be too slow for us once we start dealing with a lot of data, plus there are a lot of things that it won’t do for us automatically that are handy to have. Another choice is the Pandas Series which we’ll actually introduce in chapter 11 – oddly, that one turns out to do too much, rather than too little, for our purposes here. A happy medium is the ndarray from the NumPy package1 . Before we do that, however, we need to learn what a “package” actually is, and how to use one.

     

    1Most people seem to pronounce this “NUM-pie,” although I’ve heard “NUM-pee” as well. Pick your poison.


    8: Arrays in Python (1 of 2) is shared under a CC BY-SA license and was authored, remixed, and/or curated by Stephen Davies (allthemath.org) .

    • Was this article helpful?