Advanced Indexing Techniques on NumPy Arrays - Learn NumPy Series


Advanced Indexing Techniques on NumPy Arrays - Learn NumPy Series

*

Full Code From This Example:


YouTube Description:

This video is apart of a full Learn NumPy Series- https://www.youtube.com/watch?v=9fcTq8PDWWA&list=PLc_Ps3DdrcTuf3e-BBpDv8r9jbOB5Wdv- In this one we'll look at how we can begin using advanced indexing methods on our NumPy Arrays #Python #NumPy #Tutorial Join The Socials -- Picking Shoutouts Across YouTube, Insta, FB, and Twitter! FB - https://www.facebook.com/CodeWithDerrick/ Insta - https://www.instagram.com/codewithderrick/ Twitter - https://twitter.com/codewithderrick LinkedIn - https://www.linkedin.com/in/derricksherrill/ GitHub - https://github.com/Derrick-Sherrill We're at 4950+ Subscribers at the time of writing this! How awesome. Thanks so much everyone. Your support is phenomenal. Super honored by all the kind words and comments. ***************************************************************** Full code from the video: import numpy as np row_1 = [1,2,3,4,5] row_2 = [6,7,8,9,10] row_3 = [11,12,13,14,15] row_4 = [16,17,18,19,20] row_5 = [21,22,23,24,25] test_data = np.array([row_1,row_2,row_3,row_4,row_5]) print(test_data) # Using Python Slices print(test_data[:,2:4:1]) # Same Elements but reversed print(test_data[:,-2:-4:-1]) #boolean index greater_than_five = test_data != 5 # returns one dimensional array print(greater_than_five) # single line operation print(test_data[greater_than_five]) print(test_data[test_data!=5]) # But what if we wanted to retain shape? drop_under_5_array = np.where(test_data != 5, test_data, 0) print(drop_under_5_array) # Using Multiple Logic Conditions drop_under_5_and_over_20 = np.logical_and(test_data!=5, test_data!=20) # YouTube Description doesn't allow angled brackets :( print(drop_under_5_and_over_20) print(test_data[drop_under_5_and_over_20]) https://github.com/Derrick-Sherrill/NumPy-Udemy-Scripts/blob/master/Topic%204%20-%20Advanced%20Indexing/advanced-indexing-lesson.py Packages (& Versions) used in this video: Python 3.7 NumPy 1.17 ***************************************************************** Code from this tutorial and all my others can be found on my GitHub: https://github.com/Derrick-Sherrill/DerrickSherrill.com Check out my website: https://www.derricksherrill.com/ If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!! Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!

Enjoy this content? Consider Subbing to the Youtube channel





Derrick Sherrill

By: Derrick Sherrill

Thanks for visiting my page! I'm working hard to make the best content I can for you. I love watching people learn and teaching others. Happy Coding!

Become a Patreon!