NumPy for Data Science – Part 2

Create NumPy Arrays with Random Numbers

  • rand() – the function is used to generate value between 0 to 1.
  • randn() – the function is used to generate value close to zero. This may return positive or negative numbers as well.
  • ranf() – the function for doing random sampling in NumPy. It returns an Array of specified shape and fills it with random floats inn the half-open interval.
  • randint() – the function is used to generate a random number between given range.

Data Types in NumPy Arrays

Shape and Reshaping In NumPy Arrays

Shape of an Array

The shape of an array is the number of elements in each dimension.

Get the Shape of an Array

NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements.

Reshaping arrays

Reshaping means changing the shape of an array.

The shape of an array is the number of elements in each dimension.

By reshaping we can add or remove dimensions or change number of elements in each dimension.

NumPy for Data Science – Part 1

Popular Posts

Author

  • Naveen Pandey Data Scientist Machine Learning Engineer

    Naveen Pandey has more than 2 years of experience in data science and machine learning. He is an experienced Machine Learning Engineer with a strong background in data analysis, natural language processing, and machine learning. Holding a Bachelor of Science in Information Technology from Sikkim Manipal University, he excels in leveraging cutting-edge technologies such as Large Language Models (LLMs), TensorFlow, PyTorch, and Hugging Face to develop innovative solutions.

    View all posts
Spread the knowledge
 
  

Leave a Reply

Your email address will not be published. Required fields are marked *