Saurav Jain (Open Source + Communities) Profile picture
Developer Community Manager @Apify โ€ข ex ๐Ÿฅ‘@amplication โ€ขOpen Sourceโ€ข Web Scraping/Automation โ€ข AI โ€ข Python โ€ข JavaScript โ€ขGitHub โ€ข Node.js

Jul 21, 2021, 7 tweets

Five NumPy Functions a beginner should know about๐Ÿ๐ŸŒŸ

๐Ÿงต๐Ÿ‘‡

1โƒฃ ๐—ป๐—ฝ.๐—ฎ๐—ฟ๐—ฟ๐—ฎ๐˜†

In Numpy, we create arrays using the "array" function.

Numpy gives the power to create multi-dimensional arrays.

๐Ÿ”— Code

2โƒฃ ๐—ป๐—ฝ.๐˜€๐—ต๐—ฎ๐—ฝ๐—ฒ

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

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

๐Ÿ”— Code

3โƒฃ ๐—ป๐—ฝ.๐—ฟ๐—ฒ๐˜€๐—ต๐—ฎ๐—ฝ๐—ฒ

reshape is used to change the shape of the NumPy array without changing the elements of the array.

reshape is one the best function of NumPy, it helps a lot in calculations.

๐Ÿ”— Code

4โƒฃ ๐—ป๐—ฝ.๐—ฎ๐—ฟ๐—ผ๐˜‚๐—ป๐—ฑ

This mathematical function helps the user to evenly round array elements to given number of decimals

numpy.around(arr, decimals = 0, out = None)

decimal : [int, optional] Decimal places we want to round off

out : [optional] Output resulted array

๐Ÿ”— Code

5โƒฃ ๐—ป๐—ฝ.๐˜๐—ฟ๐—ฎ๐—ป๐˜€๐—ฝ๐—ผ๐˜€๐—ฒ

Remember, in your maths class, to find the transpose of a matrix you have to solve long calculations.

In NumPy, it can be done only in a single line using transpose.

It has no effect on a 1-D array!

๐Ÿ”— Code

Hey,

Thanks for reading the thread โค๏ธ

I post content about Python and Machine learning!!

If you like this thread, give it a retweet :)

Thanks

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling