fbpx

Numpy Cheatsheet – Fundamental Data Science Libraries

Fundamental Python Data Science Libraries – Numpy

If you are a developer and want to integrate data manipulation or science into your product or starting your journey in data science, here are the Python libraries you need to know.

  1. NumPy
  2. Pandas
  3. Matplotlib
  4. Scikit-Learn

The goal of this series is to provide introductions, highlights, and demonstrations of how to use the must-have libraries so you can pick what to explore more in depth.

NumPy

Just as it is written on NumPy’s website, this library is fundamental for scientific computing in Python. It includes powerful manipulation and mathematical functionality at super fast speeds.

Focus of the Library

This library is all about the multidimensional array. It is similar in appearance to a list & indexes like a list, but carries a much more powerful set of tools.

Installation

Open a command line and type in:

Windows: in the past I have found installing NumPy to be a headache, so I encourage all you Windows users to download Anaconda’s distribution of Python which already comes with all the mathematical and scientific libraries installed.

Details

A NumPy array differs from a list in a couple of ways.

  1. All data in a NumPy array must be of the same data type, a list can hold multiple
  2. A NumPy array is more memory efficient & faster! See a detailed explanation here
  3. Lists don’t have as many powerful mathematical methods and attributes built in! — super useful for data exploration and development.

Let’s dive in!

Creation

You can create an array in a couple of different ways.

From a list or tuple

With placeholder content

With a sequence

Upload data

Makes Math Easy

You can do all sorts of mathematical operations on the whole array. No looping required! A new array will be made with the results.

Attributes & Methods

Beyond just mathematical operations, NumPy comes with a plethora of powerful functionality that you can leverage to save yourself time & increase readability.

Summary Statistics

Additionally, there are .max(), .min(), .sum(), and plenty more.

Reshape

More Math

There are many more (too many to list) mathematical methods available. Dot is just my favorite.

I’m providing here a link to download my NumPy walkthrough using a Jupyter Notebookfor everything we covered and more!

Never used Jupyter notebooks before? Visit their website here.

See Also

Overall, if you have complex transformations you need to do on lists of data, I recommend searching for a NumPy solution before coding something yourself. This will save you many a headache.

Applications

Let’s look at a scenario. Say I was able to export trading transactions: buys & sells. I want to see how much cash I had on hand after each transaction.

This is a version with very simple, fictional data. However, what if we wanted to work with the data shown above but with the dates next to them? That’s possible, check out my next article on pandas.

Thanks for reading! If you have questions feel free to comment & I will try to get back to you.

Thanks for reading! If you have questions feel free to comment & I will try to get back to you.

Connect with me on Instagram @lauren__glassLinkedIn

Check out my essentials list on Amazon

View Comments (0)

Leave a Reply

Your email address will not be published.


© 2019 Lauren Glass. All Rights Reserved.

Scroll To Top