[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-572052-105":53,"doc-detail-572052-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","cheat-sheet-python-numpy-numpy-array-operations-and-utilities","Cheat Sheet-Python - NumPy - NumPy array operations and utilities","","Python Cheat Sheet: NumPy summarizes core NumPy array concepts and common operations in a compact reference format. It explains the shape and dimensionality of arrays, element-wise multiplication via the Hadamard product, and standard matrix multiplication using both np.matmul and the @ operator. It also covers array creation with np.arange and np.linspace, aggregation such as average, variance and standard deviation, slicing-based assignment, and utility functions like diff, cumulative sum, sort, argsort, max/argmax, and nonzero.",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":51,"@type":70,"position":76},"https://docshare.wps.com/template/general/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/cheat-sheet-python-numpy-numpy-array-operations-and-utilities/572052/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/cheat-sheet-python-numpy-numpy-array-operations-and-utilities/572052.png","ImageObject",442,249,{"name":88,"@type":89},"Stanley","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-21","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",7,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How do I check a NumPy array’s shape and number of dimensions?","Question",{"text":109,"@type":110},"Use the .shape attribute to get a tuple of integers describing the axis sizes, and .ndim to get the length of that shape tuple.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"What is the difference between element-wise multiplication and matrix multiplication in NumPy?",{"text":114,"@type":110},"Use the asterisk (*) for the Hadamard product (element-wise multiplication). Use np.matmul(a, b) or the @ operator for standard matrix multiplication.",{"name":116,"@type":107,"acceptedAnswer":117},"Which NumPy functions help with basic array statistics and ordering?",{"text":118,"@type":110},"Use np.average, np.var, and np.std for statistics, and np.sort/np.argsort for ascending sorting and retrieving the indices of the sorted order.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},572052,1792086179,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":50,"category_name":51,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":9,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":4},2336477405376,"https://ap-avatar.wpscdn.com/davatar_29158cc5080c5b710cf443261637dec0","Python Cheat Sheet: NumPy  \n“A puzzle a day to learn, code, and play” → Visit [finxter.com](finxter.com)  \n\n| Name | Description | Example |\n| --- | --- | --- |\n| a .shape | The shape attribute of NumPy array a keeps a tuple of integers. Each integer describes the number of elements of the axis. | a = np.array([[1 ,2],[1 ,1],[0 ,0]]) print(np.shape(a)) \\# (3, 2) |\n| a .ndim | The ndim attribute is equal to the length of the shape tuple. | print(np.ndim(a)) \\# 2 |\n| * | The asterisk (star) operator performs the Hadamard product, i.e., multiplies two matrices with equal shape element-wise. | a = np.array([[2 , 0], [0 , 2]])\u003Cbr>b = np.array([[1 , 1], [1 , 1]])\u003Cbr>print(a*b) \\# [[2 0] [0 2]] |\n| np.matmul(a,b), a@b | The standard matrix multiplication operator. Equivalent to the @ operator. | print(np.matmul(a,b))\u003Cbr>\\# [[2 2] [2 2]] |\n| np.arange([start, ]stop,[step, ]) | Creates a new 1D numpy array with evenly spaced values | print(np.arange(0 ,10 ,2))\u003Cbr>\\# [0 2 4 6 8] |\n| np.linspace(start, stop, num= 50) | Creates a new 1D numpy array with evenly spread elements within the given interval | print(np.linspace(0 ,10 ,3))\u003Cbr>\\# [ 0. 5. 10.] |\n| np.average(a) | Averages over all the values in the numpy array | a = np.array([[2 , 0], [0 , 2]])\u003Cbr>print(np.average(a)) \\# 1.0 |\n| \u003Cslice> = \u003Cval> | Replace the \u003Cslice> as selected by the slicing operator with the value \u003Cval> . | a = np.array([0 , 1 , 0 , 0 , 0]) a[::2] = 2\u003Cbr>print(a) \\# [2 1 2 0 2] |\n| np.var(a) | Calculates the variance of a numpy array. | a = np.array([2 , 6])\u003Cbr>print(np.var(a)) \\# 4.0 |\n| np.std(a) | Calculates the standard deviation of a numpy array | print(np.std(a)) \\# 2.0 |\n| np.diff(a) | Calculates the difference between subsequent values in NumPy array a | fibs = np.array([0 , 1 , 1 , 2 , 3 , 5]) print(np.diff(fibs, n= 1))\u003Cbr>\\# [1 0 1 1 2] |\n| np.cumsum(a) | Calculates the cumulative sum of the elements in NumPy array a. | print(np.cumsum(np.arange(5)))\u003Cbr>\\# [ 0 1 3 6 10] |\n| np.sort(a) | Creates a new NumPy array with the values from a (ascending) . | a = np.array([10 ,3 ,7 ,1 ,0]) print(np.sort(a))\u003Cbr>\\# [ 0 1 3 7 10] |\n| np.argsort(a) | Returns the indices of a NumPy array so that the indexed values would be sorted. | a = np.array([10 ,3 ,7 ,1 ,0]) print(np.argsort(a))\u003Cbr>\\# [4 3 1 2 0] |\n| np.max(a) | Returns the maximal value of NumPy array a. | a = np.array([10 ,3 ,7 ,1 ,0])\u003Cbr>print(np.max(a)) \\# 10 |\n| np.argmax(a) | Returns the index of the element with maximal value in the NumPy array a. | a = np.array([10 ,3 ,7 ,1 ,0])\u003Cbr>print(np.argmax(a)) \\# 0 |\n| np.nonzero(a) | Returns the indices of the nonzero elements in NumPy array a. | a = np.array([10 ,3 ,7 ,1 ,0])\u003Cbr>print(np.nonzero(a)) \\# [0 1 2 3] |","cbCaiuItzaP8F2SJ","https://ap.wps.com/l/cbCaiuItzaP8F2SJ","pdf",99799,"English","# NumPy Cheat Sheet\n## Array properties and indexing\n## Arithmetic and matrix operations\n## Array creation and slicing\n## Statistics, differences, and cumulative functions\n## Sorting and value lookup","[{\"question\":\"How do I check a NumPy array’s shape and number of dimensions?\",\"answer\":\"Use the .shape attribute to get a tuple of integers describing the axis sizes, and .ndim to get the length of that shape tuple.\"},{\"question\":\"What is the difference between element-wise multiplication and matrix multiplication in NumPy?\",\"answer\":\"Use the asterisk (*) for the Hadamard product (element-wise multiplication). Use np.matmul(a, b) or the @ operator for standard matrix multiplication.\"},{\"question\":\"Which NumPy functions help with basic array statistics and ordering?\",\"answer\":\"Use np.average, np.var, and np.std for statistics, and np.sort/np.argsort for ascending sorting and retrieving the indices of the sorted order.\"}]","Cheat Sheet-Python - NumPy - NumPy array operations and utilities | PDF",1791925266]