Code Monkey home page Code Monkey logo

numpy's Introduction

Introduction to NumPy

NumPy is a library that helps us handle large and multidimensional arrays and matrices. It provides a large collection of powerful methods to do multiple operations.

NumPy Arrays NumPy arrays are n-dimensional arrays containing data of the same type in the form of rows and columns. We can create these arrays in the following way:

Example of creating a numpy array:

import numpy as np #importing the module numpy and creating a short form as np arr=np.array([1,2,3,4]) #creating a numpy array print(f"The array is {arr} and the type is {type(arr)}")

NumPy arrays vs Lists The following are the reasons for giving preference to the numpy array over lists:

  1. Numpy arrays occupy lesser memory
  2. They are faster
  3. They are also comparatively convenient to use, especially when we deal with multiple dimensions

ways of creating NumPy arrays-:

  1. Using arange():
  2. Using random():
  3. Using ones():
  4. Using zeros():
  5. Using linspace():

Operations on Python NumPy Arrays

  1. Checking Data type:
  2. Finding Dimension:
  3. Finding ByteSize:
  4. Reshaping:
  5. Memory Layout:

Mathematical Functions on NumPy arrays

  1. add():
  2. subtract():
  3. multiply():
  4. divide():
  5. sqrt():

numpy's People

Contributors

alihashimi12345 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.