Python NumPy Tutorial for Novices



Study the fundamentals of the NumPy library on this tutorial for newbies. It offers background data on how NumPy works and the way it compares to Python’s Constructed-in lists. This video goes by write code with NumPy. It begins with the fundamentals of making arrays after which will get into extra superior stuff. The video covers creating arrays, indexing, math, statistics, reshaping, and extra.

💻 Code: https://github.com/KeithGalli/NumPy

🎥 Tutorial from Keith Galli. Try his YouTube channel: https://www.youtube.com/channel/UCq6XkhO5SZ66N04IcPbqNcw

⭐️ Course Contents ⭐️
⌨️ (01:15) What’s NumPy
⌨️ (01:35) NumPy vs Lists (pace, performance)
⌨️ (09:17) Purposes of NumPy
⌨️ (11:08) The Fundamentals (creating arrays, form, dimension, knowledge kind)
⌨️ (16:08) Accessing/Altering Particular Components, Rows, Columns, and so on (slicing)
⌨️ (23:14) Initializing Completely different Arrays (1s, 0s, full, random, and so on…)
⌨️ (31:34) Drawback #1 (How do you initialize this array?)
⌨️ (33:42) Watch out when copying variables!
⌨️ (35:45) Fundamental Arithmetic (arithmetic, trigonometry, and so on.)
⌨️ (38:20) Linear Algebra
⌨️ (42:19) Statistics
⌨️ (43:57) Reorganizing Arrays (reshape, vstack, hstack)
⌨️ (47:29) Load knowledge in from a file
⌨️ (50:20) Superior Indexing and Boolean Masking
⌨️ (55:59) Drawback #2 (How do you index these values?)

⭐️ Hyperlinks with extra data ⭐️
🔗 NumPy vs Lists: https://www.youtube.com/channel/UC_mmB9WkzXQAQmwj6EPmXQw
🔗 Indexing: https://docs.scipy.org/doc/numpy-1.13.0/consumer/fundamentals.indexing.html
🔗 Array Creation Routines: https://docs.scipy.org/doc/numpy/reference/routines.array-creation.html
🔗 Math Routines Docs: https://docs.scipy.org/doc/numpy/reference/routines.math.html
🔗 Linear Algebra Docs: https://docs.scipy.org/doc/numpy/reference/routines.linalg.html

Study to code without spending a dime and get a developer job: https://www.freecodecamp.org

Learn a whole lot of articles on programming: https://www.freecodecamp.org/information

source

20 thoughts on “Python NumPy Tutorial for Novices”

  1. Thanks for this primer.

    At 27:15, can you explain why one would pass integers as two arguments instead of the tuple as an argument (as was done for previous arguments of methods). It all seems kinda hit and miss.

    At 28:50, why would the key be size, and not shape?

    Why do we use ~ and & instead of "not" and "and" for the conditions.

    At 31:20, does this mean we should pass lists with double square brackets generally to np.array() to ensure we have sufficient axes so that we have the option to repeat both rows and columns if we want to.

    At 46:15, can you explain why the argument for vstack has square brackets around v1,v2. It actually makes no sense syntactically since these outside square brackets should create another dimension on top of the two dimensions that [[v1],[v2]] already have. But vstack just stacks rows; it doesn't create another dimension. So it shouldn't work, yet it does- more syntactic nonsense 😄.
    Maybe you can offer an explanation.

    Thank again for this

    Reply
  2. Traceback (most recent call last):

    File "C:UsersbrycePycharmProjectsFirstNumpy.py", line 4, in <module>

    print(np.genfromtxt('twitchdata-update.csv', delimiter=','))

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:UsersbrycePycharmProjectsFirstvenvLibsite-packagesnumpylibnpyio.py", line 1980, in genfromtxt

    fid = np.lib._datasource.open(fname, 'rt', encoding=encoding)

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:UsersbrycePycharmProjectsFirstvenvLibsite-packagesnumpylib_datasource.py", line 193, in open

    return ds.open(path, mode, encoding=encoding, newline=newline)

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    File "C:UsersbrycePycharmProjectsFirstvenvLibsite-packagesnumpylib_datasource.py", line 533, in open

    raise FileNotFoundError(f"{path} not found.")

    FileNotFoundError: twitchdata-update.csv not found.

    why is it saying this when I try to import my file like what he does around 50 minutes

    Reply
  3. 31:50 My solution (works for any shape 2D matrix):
    print()

    print('##########################')

    print('# Initialize this array: #')

    print('# #')

    print('# 1 1 1 1 1 #')

    print('# 1 0 0 0 1 #')

    print('# 1 0 9 0 1 #')

    print('# 1 0 0 0 1 #')

    print('# 1 1 1 1 1 #')

    print('# #')

    print('##########################')

    print()

    d = np.ones((10, 5))

    print('d = np.ones((5, 5))n', d)

    print()

    e = np.zeros((d.shape[0] – 2, d.shape[1] – 2))

    print('e = np.zeros((d.shape[0] – 1, d.shape[1] – 1))n', e)

    print()

    d[1:-1, 1:-1] = e

    print('d[1:-1, 1:-1] = en', d)

    print()

    d[int(d.shape[0]/2), int(d.shape[1]/2)] = 9

    print('d[int(d.shape[0]/2), int(d.shape[1]/2)] = 9n', d)

    print()

    Reply

Leave a Comment