_Python Data Science Cheat Sheet NumPy Basics 4 .pdf

DigitalMarketing583724 28 views 5 slides Feb 03, 2025
Slide 1
Slide 1 of 5
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5

About This Presentation

πŸš€ Elevate your Python skills: Easy manipulation of NumPy Arrays
NumPy arrays themselves are made specifically for easily manipulating data via high-powered functions. Talking big data or building workload optimizations with fewer resources, then chances are, you really need to absorb these.

With...


Slide Content

www.1stepgrow.com
NUMPY BASICS
PYTHON FORPYTHON FOR
DATA SCIENCEDATA SCIENCE
CHEAT SHEET PART- 4

www.1stepgrow.com
>>> i = np.transpose(b)
>>> b.ravel()
>>> h.resize((2,6))
>>> g.reshape(3,-2)
>>> np.append(h,g)
>>> np.delete(a,[1])
>>> i.T
Permute array dimensions
Flatten the array
Return a new array with
shape (2,6)
Reshape, but don’t change
data
Append items to an array
Delete items from an array
Permute array dimensions
Array Manipulation
Transposing Array
Changing Array Shape
Adding/Removing Elements

www.1stepgrow.com
>>> np.concatenate((a,d),axis=0)
array([ 1, 2, 3, 10, 15, 20])
Concatenate arrays
>>> np.r_[e,f] Stack arrays vertically
(row-wise)
>>> np.vstack((a,b))
array([[ 1. , 2. , 3. ],
[ 1.5, 2. , 3. ],[ 4. , 5. , 6. ]])
Stack arrays vertically
(row-wise)
>>> np.hstack((e,f))
array([[ 7., 7., 1., 0.],
[ 7., 7., 0., 1.]])
Stack arrays horizontally
(column-wise)
>>> np.column_stack((a,d))
array([[ 1, 10],[ 2, 15],[ 3, 20]])
Create stacked
column-wise arrays
>>> np.c_[a,d] Create stacked
column-wise arrays
Array Manipulation
Combining Arrays

www.1stepgrow.com
>>> np.hsplit(a,3)
[array([1]),array([2]),array([3])]
Split the array horizontally
at the 3rd
>>> np.vsplit(c,2)
[array([[[ 1.5, 2. , 1. ],
[ 4. , 5. , 6. ]]]),
array([[[ 3., 2., 3.],
[ 4., 5., 6.]]])]
Split the array vertically at
the 2nd index
Array Manipulation
Splitting Arrays

www.1stepgrow.com
Build your career story with
1stepGrow Academy
Follow 1stepGrow Academy
Save the Post
Share your Comments