{"id":82724,"date":"2023-12-28T10:10:45","date_gmt":"2023-12-28T03:10:45","guid":{"rendered":"https:\/\/wiki.tino.org\/staging\/?p=82724"},"modified":"2023-12-28T10:10:48","modified_gmt":"2023-12-28T03:10:48","slug":"numpy-la-gi","status":"publish","type":"post","link":"https:\/\/tino.vn\/blog\/numpy-la-gi\/","title":{"rendered":"NumPy l\u00e0 g\u00ec? T\u1ed5ng quan v\u1ec1 th\u01b0 vi\u1ec7n NumPy trong Python"},"content":{"rendered":"\n<p><strong>Khi b\u1eaft \u0111\u1ea7u kh\u00e1m ph\u00e1 s\u00e2u h\u01a1n v\u00e0o th\u1ebf gi\u1edbi phong ph\u00fa c\u1ee7a <strong><a href=\"https:\/\/tino.vn\/blog\/python-la-gi\/\" target=\"_blank\" data-type=\"post\" data-id=\"16155\" rel=\"noreferrer noopener\">l\u1eadp tr\u00ecnh Python<\/a><\/strong>, b\u1ea1n kh\u00f4ng th\u1ec3 b\u1ecf qua m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd m\u00e0 h\u1ea7u h\u1ebft c\u00e1c nh\u00e0 khoa h\u1ecdc d\u1eef li\u1ec7u v\u00e0 nh\u00e0 nghi\u00ean c\u1ee9u s\u1eed d\u1ee5ng. \u0110\u00f3 l\u00e0 NumPy. V\u1eady c\u1ee5 th\u1ec3 NumPy l\u00e0 g\u00ec? C\u00e1c b\u1ea1n h\u00e3y c\u00f9ng TinoHost t\u00ecm hi\u1ec3u qua b\u00e0i vi\u1ebft d\u01b0\u1edbi \u0111\u00e2y nh\u00e9!<\/strong><\/p>\n\n\n\n<h2 id=\"T\u1ed5ng_quan_v\u1ec1_NumPy\"><a id=\"post-82724-_p3kbnfsanap7\"><\/a><strong>T\u1ed5ng quan v\u1ec1 NumPy<\/strong><\/h2>\n\n\n\n<h3 id=\"NumPy_l\u00e0_g\u00ec?\"><a id=\"post-82724-_r0z53wymp6aj\"><\/a><strong>NumPy l\u00e0 g\u00ec?<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/numpy.org\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/numpy.org\/\" rel=\"noreferrer noopener nofollow\">NumPy<\/a> (vi\u1ebft t\u1eaft c\u1ee7a <strong>Numerical Python<\/strong>) l\u00e0 m\u1ed9t th\u01b0 vi\u1ec7n quan tr\u1ecdng trong l\u1eadp tr\u00ecnh Python. C\u00f4ng c\u1ee5 n\u00e0y \u0111\u01b0\u1ee3c t\u1ea1o ra b\u1edfi m\u1ed9t c\u1ed9ng \u0111\u1ed3ng c\u00e1c nh\u00e0 nghi\u00ean c\u1ee9u v\u00e0 nh\u00e0 ph\u00e1t tri\u1ec3n v\u1edbi m\u1ee5c \u0111\u00edch gi\u00fap c\u00e1c l\u1eadp tr\u00ecnh vi\u00ean thao t\u00e1c d\u1eef li\u1ec7u s\u1ed1 h\u1ecdc v\u00e0 th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n to\u00e1n h\u1ecdc ph\u1ee9c t\u1ea1p m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3.<\/p>\n\n\n\n<p>M\u1ed9t trong nh\u1eefng \u01b0u \u0111i\u1ec3m n\u1ed5i b\u1eadt c\u1ee7a NumPy l\u00e0 kh\u1ea3 n\u0103ng l\u00e0m vi\u1ec7c v\u1edbi m\u1ea3ng \u0111a chi\u1ec1u (arrays) v\u00e0 ma tr\u1eadn, cho ph\u00e9p l\u01b0u tr\u1eef v\u00e0 x\u1eed l\u00fd d\u1eef li\u1ec7u d\u1ec5 d\u00e0ng. \u0110\u00e2y kh\u00f4ng ch\u1ec9 l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 h\u1eefu \u00edch cho c\u00e1c nh\u00e0 khoa h\u1ecdc d\u1eef li\u1ec7u, m\u00e0 c\u00f2n l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn tuy\u1ec7t v\u1eddi cho nh\u1eefng ng\u01b0\u1eddi l\u00e0m vi\u1ec7c trong c\u00e1c l\u0129nh v\u1ef1c nh\u01b0 khoa h\u1ecdc m\u00e1y t\u00ednh, x\u1eed l\u00fd \u1ea3nh v\u00e0 th\u1ecb gi\u00e1c m\u00e1y t\u00ednh.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-1.webp\" alt=\"numpy-viet-tat-cua-numerical-python-la-mot-thu-vien-quan-trong-trong-lap-trinh-python\" class=\"wp-image-82754\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-1.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-1-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>NumPy (vi\u1ebft t\u1eaft c\u1ee7a <em>Numerical Python<\/em>) l\u00e0 m\u1ed9t th\u01b0 vi\u1ec7n quan tr\u1ecdng trong l\u1eadp tr\u00ecnh Python<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p>NumPy cung c\u1ea5p m\u1ed9t lo\u1ea1t c\u00e1c h\u00e0m v\u00e0 ph\u01b0\u01a1ng ph\u00e1p gi\u00fap th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n to\u00e1n h\u1ecdc, th\u1ed1ng k\u00ea v\u00e0 bi\u1ec3u \u0111\u1ed3 h\u00f3a d\u1eef li\u1ec7u v\u00f4 c\u00f9ng linh ho\u1ea1t. \u0110\u1ed3ng th\u1eddi, \u0111\u00e2y c\u0169ng l\u00e0 m\u1ed9t ph\u1ea7n quan tr\u1ecdng c\u1ee7a h\u1ec7 sinh th\u00e1i c\u00e1c th\u01b0 vi\u1ec7n t\u00ednh to\u00e1n trong Python. V\u1edbi NumPy, vi\u1ec7c x\u1eed l\u00fd d\u1eef li\u1ec7u s\u1ed1 h\u1ecdc tr\u1edf n\u00ean d\u1ec5 d\u00e0ng v\u00e0 hi\u1ec7u qu\u1ea3 h\u01a1n, gi\u00fap Python tr\u1edf th\u00e0nh m\u1ed9t trong nh\u1eefng ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh ph\u1ed5 bi\u1ebfn nh\u1ea5t trong l\u0129nh v\u1ef1c khoa h\u1ecdc d\u1eef li\u1ec7u v\u00e0 nghi\u00ean c\u1ee9u to\u00e1n h\u1ecdc.<\/p>\n\n\n\n<h3 id=\"C\u00e1c_t\u00ednh_n\u0103ng_n\u1ed5i_b\u1eadt_c\u1ee7a_NumPy\"><a id=\"post-82724-_25kk5xe4zeyd\"><\/a><strong>C\u00e1c t\u00ednh n\u0103ng n\u1ed5i b\u1eadt c\u1ee7a NumPy<\/strong><\/h3>\n\n\n\n<h4 id=\"M\u1ea3ng_\u0111a_chi\u1ec1u_(Arrays)\"><a id=\"post-82724-_j6s2b3bclzxv\"><\/a><strong>M\u1ea3ng \u0111a chi\u1ec1u (Arrays)<\/strong><\/h4>\n\n\n\n<p>NumPy cho ph\u00e9p t\u1ea1o ra v\u00e0 qu\u1ea3n l\u00fd c\u00e1c Arrays (m\u1ea3ng), gi\u00fap l\u01b0u tr\u1eef d\u1eef li\u1ec7u s\u1ed1 h\u1ecdc m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng v\u00e0 hi\u1ec7u qu\u1ea3. Nh\u1edd \u0111\u00f3, vi\u1ec7c x\u1eed l\u00fd c\u00e1c t\u1eadp d\u1eef li\u1ec7u ph\u1ee9c t\u1ea1p tr\u1edf n\u00ean thu\u1eadn ti\u1ec7n h\u01a1n.<\/p>\n\n\n\n<h4 id=\"Ph\u00e9p_to\u00e1n_s\u1ed1_h\u1ecdc\"><a id=\"post-82724-_l0vd3ystx0f8\"><\/a><strong>Ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc<\/strong><\/h4>\n\n\n\n<p>NumPy cung c\u1ea5p c\u00e1c ph\u00e9p to\u00e1n to\u00e1n h\u1ecdc nh\u01b0 c\u1ed9ng, tr\u1eeb, nh\u00e2n, chia tr\u00ean m\u1ea3ng d\u1eef li\u1ec7u nhanh ch\u00f3ng. C\u00e1c ph\u00e9p to\u00e1n n\u00e0y \u0111\u01b0\u1ee3c t\u1ed1i \u01b0u h\u00f3a \u0111\u1ec3 x\u1eed l\u00fd d\u1eef li\u1ec7u l\u1edbn hi\u1ec7u qu\u1ea3 h\u01a1n.<\/p>\n\n\n\n<h4 id=\"Ph\u00e9p_to\u00e1n_Vectorized\"><a id=\"post-82724-_5dggkwf5euwy\"><\/a><strong>Ph\u00e9p to\u00e1n Vectorized<\/strong><\/h4>\n\n\n\n<p>NumPy cho ph\u00e9p th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n tr\u00ean to\u00e0n b\u1ed9 m\u1ea3ng d\u1eef li\u1ec7u, kh\u00f4ng c\u1ea7n vi\u1ebft v\u00f2ng l\u1eb7p. \u0110i\u1ec1u n\u00e0y gi\u00fap t\u0103ng t\u1ed1c \u0111\u1ed9 x\u1eed l\u00fd d\u1eef li\u1ec7u \u0111\u00e1ng k\u1ec3 so v\u1edbi vi\u1ec7c s\u1eed d\u1ee5ng c\u00e1c danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng trong Python.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-2.webp\" alt=\"phep-toan-Vectorized\" class=\"wp-image-82755\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-2.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-2-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>Ph\u00e9p to\u00e1n Vectorized<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"Broadcasting\"><a id=\"post-82724-_rdkirkpdpf2b\"><\/a><strong>Broadcasting<\/strong><\/h4>\n\n\n\n<p>NumPy t\u1ef1 \u0111\u1ed9ng m\u1edf r\u1ed9ng k\u00edch th\u01b0\u1edbc c\u1ee7a c\u00e1c m\u1ea3ng \u0111\u1ec3 ph\u00f9 h\u1ee3p v\u1edbi nhau trong c\u00e1c ph\u00e9p to\u00e1n. Do \u0111\u00f3, c\u00e1c ph\u00e9p to\u00e1n gi\u1eefa c\u00e1c m\u1ea3ng c\u00f3 k\u00edch th\u01b0\u1edbc kh\u00e1c nhau c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n m\u00e0 kh\u00f4ng c\u1ea7n ph\u1ea3i thay \u0111\u1ed5i k\u00edch th\u01b0\u1edbc c\u1ee7a ch\u00fang theo c\u00e1ch th\u1ee7 c\u00f4ng.<\/p>\n\n\n\n<h4 id=\"H\u00e0m_to\u00e1n_h\u1ecdc_v\u00e0_th\u1ed1ng_k\u00ea\"><a id=\"post-82724-_jqs50y6b45qi\"><\/a><strong>H\u00e0m to\u00e1n h\u1ecdc v\u00e0 th\u1ed1ng k\u00ea<\/strong><\/h4>\n\n\n\n<p>NumPy cung c\u1ea5p m\u1ed9t lo\u1ea1t c\u00e1c h\u00e0m to\u00e1n h\u1ecdc v\u00e0 th\u1ed1ng k\u00ea nh\u01b0 sin, cos, mean, median, std,&#8230;\u0111\u1ec3 x\u1eed l\u00fd d\u1eef li\u1ec7u s\u1ed1 h\u1ecdc.<\/p>\n\n\n\n<h4 id=\"Indexing_v\u00e0_Slicing\"><strong>Indexing v\u00e0 Slicing<\/strong><\/h4>\n\n\n\n<p>NumPy h\u1ed7 tr\u1ee3 c\u00e1c ph\u00e9p indexing v\u00e0 slicing tr\u00ean m\u1ea3ng d\u1eef li\u1ec7u gi\u00fap b\u1ea1n truy c\u1eadp v\u00e0 ch\u1ec9nh s\u1eeda d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng.<\/p>\n\n\n\n<h4 id=\"Ph\u00e9p_to\u00e1n_tr\u00ean_m\u1ea3ng_logic\"><a id=\"post-82724-_nkyq2tzg067b\"><\/a><strong>Ph\u00e9p to\u00e1n tr\u00ean m\u1ea3ng logic<\/strong><\/h4>\n\n\n\n<p>NumPy cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n logic nh\u01b0 AND, OR, NOT tr\u00ean m\u1ea3ng d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng.<\/p>\n\n\n\n<h4 id=\"Ph\u00e9p_to\u00e1n_\u0111\u1ea1i_s\u1ed1_tuy\u1ebfn_t\u00ednh\"><a id=\"post-82724-_w5q0csam0yop\"><\/a><strong>Ph\u00e9p to\u00e1n \u0111\u1ea1i s\u1ed1 tuy\u1ebfn t\u00ednh<\/strong><\/h4>\n\n\n\n<p>NumPy cung c\u1ea5p nhi\u1ec1u h\u00e0m v\u00e0 ph\u01b0\u01a1ng th\u1ee9c \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n \u0111\u1ea1i s\u1ed1 tuy\u1ebfn t\u00ednh nh\u01b0 ma tr\u1eadn chuy\u1ec3n v\u1ecb, nh\u00e2n ma tr\u1eadn, gi\u1ea3i h\u1ec7 ph\u01b0\u01a1ng tr\u00ecnh tuy\u1ebfn t\u00ednh v\u00e0 nhi\u1ec1u thu\u1eadt to\u00e1n kh\u00e1c.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-3.webp\" alt=\"numpy-cung-cap-nhieu-ham-de-thuc-hien-cac-phep-toan-dai-so-tuyen-tinh\" class=\"wp-image-82756\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-3.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-3-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>NumPy cung c\u1ea5p nhi\u1ec1u h\u00e0m \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n \u0111\u1ea1i s\u1ed1 tuy\u1ebfn t\u00ednh <\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"L\u00e0m_vi\u1ec7c_v\u1edbi_d\u1eef_li\u1ec7u_\u0111a_chi\u1ec1u\"><a id=\"post-82724-_sfrjs8qkdtff\"><\/a><strong>L\u00e0m vi\u1ec7c v\u1edbi d\u1eef li\u1ec7u \u0111a chi\u1ec1u<\/strong><\/h4>\n\n\n\n<p>NumPy cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n tr\u00ean d\u1eef li\u1ec7u \u0111a chi\u1ec1u, th\u00edch h\u1ee3p cho vi\u1ec7c x\u1eed l\u00fd h\u00ecnh \u1ea3nh, \u00e2m thanh v\u00e0 c\u00e1c d\u1eef li\u1ec7u khoa h\u1ecdc kh\u00e1c.<\/p>\n\n\n\n<h4 id=\"T\u00edch_h\u1ee3p_C_v\u1edbi_Python\"><a id=\"post-82724-_jcjtdjxqdv75\"><\/a><strong>T\u00edch h\u1ee3p C v\u1edbi Python<\/strong><\/h4>\n\n\n\n<p>NumPy \u0111\u01b0\u1ee3c vi\u1ebft b\u1eb1ng ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh C, \u0111i\u1ec1u n\u00e0y gi\u00fap t\u0103ng hi\u1ec7u su\u1ea5t c\u1ee7a c\u00e1c ph\u00e9p to\u00e1n, \u0111\u1eb7c bi\u1ec7t l\u00e0 tr\u00ean c\u00e1c m\u1ea3ng d\u1eef li\u1ec7u l\u1edbn.<\/p>\n\n\n\n<h4 id=\"T\u00edch_h\u1ee3p_v\u1edbi_c\u00e1c_th\u01b0_vi\u1ec7n_kh\u00e1c\"><a id=\"post-82724-_g2y0lg3bp6o3\"><\/a><strong>T\u00edch h\u1ee3p v\u1edbi c\u00e1c th\u01b0 vi\u1ec7n kh\u00e1c<\/strong><\/h4>\n\n\n\n<p>C\u1ed9ng \u0111\u1ed3ng ng\u01b0\u1eddi d\u00f9ng NumPy l\u1edbn m\u1ea1nh, \u0111i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 s\u1ebd c\u00f3 r\u1ea5t nhi\u1ec1u c\u00e1c th\u01b0 vi\u1ec7n v\u00e0 c\u00f4ng c\u1ee5 kh\u00e1c trong h\u1ec7 sinh th\u00e1i c\u1ee7a Python \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng d\u1ef1a tr\u00ean NumPy.<\/p>\n\n\n\n<p>\u0110\u1ed3ng th\u1eddi, NumPy c\u0169ng t\u01b0\u01a1ng th\u00edch t\u1ed1t v\u1edbi nhi\u1ec1u th\u01b0 vi\u1ec7n v\u00e0<a href=\"https:\/\/tino.vn\/blog\/framework-la-gi\/\" target=\"_blank\" data-type=\"post\" data-id=\"16006\" rel=\"noreferrer noopener\"> framework <\/a>kh\u00e1c trong h\u1ec7 sinh th\u00e1i c\u1ee7a Python, gi\u00fap b\u1ea1n d\u1ec5 d\u00e0ng t\u00edch h\u1ee3p v\u00e0o c\u00e1c d\u1ef1 \u00e1n l\u1edbn v\u00e0 ph\u1ee9c t\u1ea1p.<\/p>\n\n\n\n<h3 id=\"M\u1ed9t_s\u1ed1_h\u1ea1n_ch\u1ebf_c\u1ee7a_NumPy\"><a id=\"post-82724-_3iccia1ekavb\"><\/a><strong>M\u1ed9t s\u1ed1 h\u1ea1n ch\u1ebf c\u1ee7a NumPy<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u0110\u1ed1i v\u1edbi ng\u01b0\u1eddi m\u1edbi h\u1ecdc l\u1eadp tr\u00ecnh ho\u1eb7c Python, vi\u1ec7c s\u1eed d\u1ee5ng NumPy c\u00f3 th\u1ec3 \u0111\u00f2i h\u1ecfi m\u1ed9t th\u1eddi gian \u0111\u1ec3 n\u1eafm v\u1eefng c\u00fa ph\u00e1p v\u00e0 c\u00e1c ch\u1ee9c n\u0103ng c\u1ee7a th\u01b0 vi\u1ec7n n\u00e0y.<\/li>\n\n\n\n<li>Trong m\u1ed9t s\u1ed1 \u1ee9ng d\u1ee5ng nh\u01b0 web development, NumPy c\u00f3 th\u1ec3 kh\u00f4ng c\u1ea7n thi\u1ebft v\u00e0 kh\u00f4ng hi\u1ec7u qu\u1ea3 so v\u1edbi c\u00e1c th\u01b0 vi\u1ec7n kh\u00e1c ho\u1eb7c khi s\u1eed d\u1ee5ng ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh kh\u00e1c.<\/li>\n\n\n\n<li>C\u00e1c m\u1ea3ng d\u1eef li\u1ec7u trong NumPy c\u00f3 th\u1ec3 t\u1ed1n nhi\u1ec1u b\u1ed9 nh\u1edb h\u01a1n so v\u1edbi c\u00e1c danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng trong Python. \u0110i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 l\u00e0 m\u1ed9t v\u1ea5n \u0111\u1ec1 \u0111\u1ed1i v\u1edbi c\u00e1c \u1ee9ng d\u1ee5ng y\u00eau c\u1ea7u ti\u1ebft ki\u1ec7m b\u1ed9 nh\u1edb.<\/li>\n\n\n\n<li>T\u00ednh n\u0103ng broadcasting c\u00f3 th\u1ec3 d\u1eabn \u0111\u1ebfn k\u1ebft qu\u1ea3 kh\u00f4ng mong mu\u1ed1n n\u1ebfu kh\u00f4ng s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1ch, \u0111\u1eb7c bi\u1ec7t \u0111\u1ed1i v\u1edbi ng\u01b0\u1eddi m\u1edbi h\u1ecdc s\u1eed d\u1ee5ng NumPy.<\/li>\n<\/ul>\n\n\n\n<h3 id=\"\u0110\u1ed1i_t\u01b0\u1ee3ng_ki\u1ec3u_d\u1eef_li\u1ec7u_(dtype)_trong_NumPy\"><a id=\"post-82724-_bzbdd0c36y95\"><\/a><strong>\u0110\u1ed1i t\u01b0\u1ee3ng ki\u1ec3u d\u1eef li\u1ec7u (dtype) trong NumPy<\/strong><\/h3>\n\n\n\n<h4 id=\"S\u1ed1_nguy\u00ean\"><a id=\"post-82724-_yloh02jkgfwh\"><\/a><strong>S\u1ed1 nguy\u00ean<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;1, 2, 3, 4], dtype='int32')<\/code><\/pre>\n\n\n\n<p># dtype c\u1ee7a arr l\u00e0 int32<\/p>\n\n\n\n<h4 id=\"S\u1ed1_th\u1ef1c\"><a id=\"post-82724-_egyc2b8yox7z\"><\/a><strong>S\u1ed1 th\u1ef1c<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;1.1, 2.2, 3.3], dtype='float64')<\/code><\/pre>\n\n\n\n<p># dtype c\u1ee7a arr l\u00e0 float64<\/p>\n\n\n\n<h4 id=\"S\u1ed1_nguy\u00ean_kh\u00f4ng_d\u1ea5u\"><a id=\"post-82724-_tjj0c3sv71ck\"><\/a><strong>S\u1ed1 nguy\u00ean kh\u00f4ng d\u1ea5u<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;0, 1, 2], dtype='uint8')<\/code><\/pre>\n\n\n\n<p># dtype c\u1ee7a arr l\u00e0 uint8 (8-bit s\u1ed1 nguy\u00ean kh\u00f4ng d\u1ea5u)<\/p>\n\n\n\n<h4 id=\"Chu\u1ed7i_k\u00fd_t\u1ef1\"><a id=\"post-82724-_e5briaix9aq2\"><\/a><strong>Chu\u1ed7i k\u00fd t\u1ef1<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;'apple', 'banana', 'cherry'], dtype='str')<\/code><\/pre>\n\n\n\n<p># dtype c\u1ee7a arr l\u00e0 str (chu\u1ed7i k\u00fd t\u1ef1)<\/p>\n\n\n\n<p>Ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y c\u1ee7a Python:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;1, 2, 3], dtype=object)<\/code><\/pre>\n\n\n\n<p># dtype c\u1ee7a arr l\u00e0 object (ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y c\u1ee7a Python)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-4.webp\" alt=\"doi-tuong-kieu-du-lieu-dtype-trong-numpy\" class=\"wp-image-82757\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-4.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-4-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>\u0110\u1ed1i t\u01b0\u1ee3ng ki\u1ec3u d\u1eef li\u1ec7u (dtype) trong NumPy<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"Ki\u1ec3u_d\u1eef_li\u1ec7u_t\u00f9y_ch\u1ec9nh\"><a id=\"post-82724-_9mab6vm2r10t\"><\/a><strong>Ki\u1ec3u d\u1eef li\u1ec7u t\u00f9y ch\u1ec9nh<\/strong><\/h4>\n\n\n\n<p>Ngo\u00e0i ra, NumPy cho ph\u00e9p \u0111\u1ecbnh ngh\u0129a c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u t\u00f9y ch\u1ec9nh, gi\u00fap x\u00e1c \u0111\u1ecbnh c\u00e1ch d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef v\u00e0 x\u1eed l\u00fd.<\/p>\n\n\n\n<p>Vi\u1ec7c hi\u1ec3u v\u00e0 qu\u1ea3n l\u00fd \u0111\u00fang \u0111\u1ed1i t\u01b0\u1ee3ng ki\u1ec3u d\u1eef li\u1ec7u trong NumPy l\u00e0 \u0111i\u1ec1u quan tr\u1ecdng \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c c\u0169ng nh\u01b0 hi\u1ec7u su\u1ea5t c\u1ee7a c\u00e1c ph\u00e9p to\u00e1n trong qu\u00e1 tr\u00ecnh l\u1eadp tr\u00ecnh.<\/p>\n\n\n\n<h3 id=\"C\u00e1c_ph\u01b0\u01a1ng_th\u1ee9c_trong_Numpy\"><a id=\"post-82724-_7mrzfbkt2vp0\"><\/a><strong>C\u00e1c ph\u01b0\u01a1ng th\u1ee9c trong Numpy<\/strong><\/h3>\n\n\n\n<h4 id=\"Ph\u01b0\u01a1ng_th\u1ee9c_t\u1ea1o_m\u1ea3ng\"><a id=\"post-82724-_a6cdukvuiz9i\"><\/a><strong>Ph\u01b0\u01a1ng th\u1ee9c t\u1ea1o m\u1ea3ng<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>np.array():<\/strong> T\u1ea1o m\u1ea3ng t\u1eeb m\u1ed9t danh s\u00e1ch ho\u1eb7c tuple.<\/li>\n\n\n\n<li><strong>np.zeros(shape): <\/strong>T\u1ea1o m\u1ea3ng v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c ph\u1ea7n t\u1eed l\u00e0 0.<\/li>\n\n\n\n<li><strong>np.ones(shape):<\/strong> T\u1ea1o m\u1ea3ng v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c ph\u1ea7n t\u1eed l\u00e0 1.<\/li>\n\n\n\n<li><strong>np.random.rand(shape):<\/strong> T\u1ea1o m\u1ea3ng v\u1edbi c\u00e1c gi\u00e1 tr\u1ecb ng\u1eabu nhi\u00ean t\u1eeb ph\u00e2n ph\u1ed1i \u0111\u1ec1u.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"Ph\u01b0\u01a1ng_th\u1ee9c_thao_t\u00e1c_d\u1eef_li\u1ec7u\"><a id=\"post-82724-_f8emoelbajdv\"><\/a><strong>Ph\u01b0\u01a1ng th\u1ee9c thao t\u00e1c d\u1eef li\u1ec7u<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>np.shape(): <\/strong>Tr\u1ea3 v\u1ec1 h\u00ecnh d\u1ea1ng (k\u00edch th\u01b0\u1edbc) c\u1ee7a m\u1ea3ng.<\/li>\n\n\n\n<li><strong>np.reshape(new_shape):<\/strong> Thay \u0111\u1ed5i h\u00ecnh d\u1ea1ng c\u1ee7a m\u1ea3ng.<\/li>\n\n\n\n<li><strong>np.concatenate((arr1, arr2), axis): <\/strong>Gh\u00e9p c\u00e1c m\u1ea3ng theo tr\u1ee5c \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh.<\/li>\n\n\n\n<li><strong>np.split(arr, indices_or_sections, axis): <\/strong>Chia m\u1ea3ng th\u00e0nh c\u00e1c m\u1ea3ng con.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-5.webp\" alt=\"cac-phuong-thuc-trong-numpy\" class=\"wp-image-82758\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-5.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-5-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>C\u00e1c ph\u01b0\u01a1ng th\u1ee9c trong Numpy<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"Ph\u01b0\u01a1ng_th\u1ee9c_to\u00e1n_h\u1ecdc_v\u00e0_th\u1ed1ng_k\u00ea\"><a id=\"post-82724-_zi3wqssgt3yp\"><\/a><strong>Ph\u01b0\u01a1ng th\u1ee9c to\u00e1n h\u1ecdc v\u00e0 th\u1ed1ng k\u00ea<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>np.sum(arr): <\/strong>T\u1ed5ng c\u00e1c ph\u1ea7n t\u1eed trong m\u1ea3ng.<\/li>\n\n\n\n<li><strong>np.mean(arr): <\/strong>Trung b\u00ecnh c\u00e1c ph\u1ea7n t\u1eed trong m\u1ea3ng.<\/li>\n\n\n\n<li><strong>np.max(arr), np.min(arr): <\/strong>Gi\u00e1 tr\u1ecb l\u1edbn nh\u1ea5t v\u00e0 nh\u1ecf nh\u1ea5t trong m\u1ea3ng.<\/li>\n\n\n\n<li><strong>np.std(arr):<\/strong> \u0110\u1ed9 l\u1ec7ch chu\u1ea9n c\u1ee7a d\u1eef li\u1ec7u.<\/li>\n\n\n\n<li><strong>np.dot(arr1, arr2):<\/strong> T\u00edch v\u00f4 h\u01b0\u1edbng c\u1ee7a hai m\u1ea3ng.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"Ph\u01b0\u01a1ng_th\u1ee9c_truy_c\u1eadp_v\u00e0_thay_\u0111\u1ed5i_ph\u1ea7n_t\u1eed_\"><a id=\"post-82724-_lbmaeciygnhw\"><\/a><strong>Ph\u01b0\u01a1ng th\u1ee9c truy c\u1eadp v\u00e0 thay \u0111\u1ed5i ph\u1ea7n t\u1eed <\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>arr[index]: <\/strong>Truy c\u1eadp ph\u1ea7n t\u1eed t\u1ea1i ch\u1ec9 s\u1ed1 index trong m\u1ea3ng.<\/li>\n\n\n\n<li><strong>arr[start:stop:step]: <\/strong>Truy c\u1eadp c\u00e1c ph\u1ea7n t\u1eed t\u1eeb v\u1ecb tr\u00ed start \u0111\u1ebfn stop v\u1edbi b\u01b0\u1edbc step.<\/li>\n\n\n\n<li><strong>arr[index] = new_value: <\/strong>G\u00e1n gi\u00e1 tr\u1ecb m\u1edbi cho ph\u1ea7n t\u1eed t\u1ea1i ch\u1ec9 s\u1ed1 index trong m\u1ea3ng.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"C\u00e1ch_s\u1eed_d\u1ee5ng_NumPy_c\u01a1_b\u1ea3n\"><a id=\"post-82724-_xwaj5j9whgyn\"><\/a><strong>C\u00e1ch s\u1eed d\u1ee5ng NumPy c\u01a1 b\u1ea3n<\/strong><\/h2>\n\n\n\n<h4 id=\"Nh\u1eadp_th\u01b0_vi\u1ec7n\"><a id=\"post-82724-_w5pl2is96aw0\"><\/a><strong>Nh\u1eadp th\u01b0 vi\u1ec7n<\/strong><\/h4>\n\n\n\n<p>Tr\u01b0\u1edbc ti\u00ean, b\u1ea1n c\u1ea7n import th\u01b0 vi\u1ec7n NumPy v\u00e0o ch\u01b0\u01a1ng tr\u00ecnh Python c\u1ee7a m\u00ecnh. Th\u00f4ng th\u01b0\u1eddng, ng\u01b0\u1eddi ta s\u1ebd s\u1eed d\u1ee5ng <strong>np<\/strong> nh\u01b0 m\u1ed9t bi\u1ebfn t\u1eaft cho NumPy \u0111\u1ec3 g\u00f5 ng\u1eafn g\u1ecdn h\u01a1n:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np<\/code><\/pre>\n\n\n\n<h4 id=\"T\u1ea1o_m\u1ea3ng_(Arrays)\"><a id=\"post-82724-_ww56byn5r752\"><\/a><strong>T\u1ea1o m\u1ea3ng (Arrays)<\/strong><\/h4>\n\n\n\n<p>S\u1eed d\u1ee5ng np.array() \u0111\u1ec3 t\u1ea1o m\u1ed9t m\u1ea3ng. V\u00ed d\u1ee5, \u0111\u1ec3 t\u1ea1o m\u1ed9t m\u1ea3ng t\u1eeb m\u1ed9t danh s\u00e1ch:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;1, 2, 3, 4, 5])<\/code><\/pre>\n\n\n\n<h4 id=\"Th\u1ef1c_hi\u1ec7n_c\u00e1c_ph\u00e9p_to\u00e1n_c\u01a1_b\u1ea3n\"><a id=\"post-82724-_o1eovd7fglyq\"><\/a><strong>Th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n c\u01a1 b\u1ea3n<\/strong><\/h4>\n\n\n\n<p>NumPy cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n to\u00e1n h\u1ecdc tr\u00ean m\u1ea3ng m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng. V\u00ed d\u1ee5, \u0111\u1ec3 c\u1ed9ng hai m\u1ea3ng:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr1 = np.array(&#091;1, 2, 3])\n\narr2 = np.array(&#091;4, 5, 6])\n\nresult = np.add(arr1, arr2)<\/code><\/pre>\n\n\n\n<h4 id=\"Ph\u00e9p_to\u00e1n_\u0111\u1ea1i_s\u1ed1_tuy\u1ebfn_t\u00ednh\"><a id=\"post-82724-_6svajqpwthyd\"><\/a><strong>Ph\u00e9p to\u00e1n \u0111\u1ea1i s\u1ed1 tuy\u1ebfn t\u00ednh<\/strong><\/h4>\n\n\n\n<p>S\u1eed d\u1ee5ng c\u00e1c h\u00e0m nh\u01b0 np.dot() \u0111\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n \u0111\u1ea1i s\u1ed1 tuy\u1ebfn t\u00ednh nh\u01b0 nh\u00e2n ma tr\u1eadn:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>matrix1 = np.array(&#091;&#091;1, 2], &#091;3, 4]])\n\nmatrix2 = np.array(&#091;&#091;5, 6], &#091;7, 8]])\n\nresult = np.dot(matrix1, matrix2)<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-6.webp\" alt=\"cach-su-dung-numpy-co-ban\" class=\"wp-image-82759\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-6.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-6-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>C\u00e1ch s\u1eed d\u1ee5ng NumPy c\u01a1 b\u1ea3n<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"S\u1eed_d\u1ee5ng_h\u00e0m_th\u1ed1ng_k\u00ea_v\u00e0_to\u00e1n_h\u1ecdc\"><a id=\"post-82724-_3i97a5ub8xqa\"><\/a><strong>S\u1eed d\u1ee5ng h\u00e0m th\u1ed1ng k\u00ea v\u00e0 to\u00e1n h\u1ecdc<\/strong><\/h4>\n\n\n\n<p>NumPy cung c\u1ea5p nhi\u1ec1u h\u00e0m th\u1ed1ng k\u00ea v\u00e0 to\u00e1n h\u1ecdc nh\u01b0 np.mean(), np.sum(), np.sqrt(), gi\u00fap thao t\u00e1c d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch linh ho\u1ea1t:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr = np.array(&#091;1, 2, 3, 4, 5])\n\nmean_value = np.mean(arr)\n\nsum_value = np.sum(arr)<\/code><\/pre>\n\n\n\n<h4 id=\"Broadcasting\"><a id=\"post-82724-_po7hf9yhbhcr\"><\/a><strong>Broadcasting<\/strong><\/h4>\n\n\n\n<p>Broadcasting cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n tr\u00ean c\u00e1c m\u1ea3ng c\u00f3 h\u00ecnh d\u1ea1ng kh\u00e1c nhau m\u1ed9t c\u00e1ch t\u1ef1 \u0111\u1ed9ng:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>arr1 = np.array(&#091;1, 2, 3])\n\nscalar = 2\n\nresult = arr1 * scalar # K\u1ebft qu\u1ea3: &#091;2, 4, 6]<\/code><\/pre>\n\n\n\n<h4 id=\"Truy_c\u1eadp_v\u00e0_c\u1eaft_l\u1ea5y_ph\u1ea7n_t\u1eed_trong_m\u1ea3ng\"><a id=\"post-82724-_b97cf3uvmnk1\"><\/a><strong>Truy c\u1eadp v\u00e0 c\u1eaft l\u1ea5y ph\u1ea7n t\u1eed trong m\u1ea3ng<\/strong><\/h4>\n\n\n\n<p>S\u1eed d\u1ee5ng ch\u1ec9 s\u1ed1 \u0111\u1ec3 truy c\u1eadp v\u00e0 c\u1eaft l\u1ea5y c\u00e1c ph\u1ea7n t\u1eed trong m\u1ea3ng NumPy nh\u01b0 b\u1ea1n l\u00e0m v\u1edbi danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng.<\/p>\n\n\n\n<h2 id=\"V\u00ed_d\u1ee5_m\u1ed9t_b\u00e0i_to\u00e1n_\u0111\u01a1n_gi\u1ea3n_s\u1eed_d\u1ee5ng_th\u01b0_vi\u1ec7n_NumPy\"><a id=\"post-82724-_y7uxyczaa2ae\"><\/a><strong>V\u00ed d\u1ee5 m\u1ed9t b\u00e0i to\u00e1n \u0111\u01a1n gi\u1ea3n s\u1eed d\u1ee5ng th\u01b0 vi\u1ec7n NumPy<\/strong><\/h2>\n\n\n\n<p>Gi\u1ea3 s\u1eed b\u1ea1n c\u00f3 m\u1ed9t danh s\u00e1ch \u0111i\u1ec3m s\u1ed1 c\u1ee7a sinh vi\u00ean trong m\u1ed9t l\u1edbp h\u1ecdc v\u00e0 b\u1ea1n mu\u1ed1n t\u00ednh \u0111i\u1ec3m trung b\u00ecnh c\u1ee7a l\u1edbp \u0111\u00f3 b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng th\u01b0 vi\u1ec7n NumPy.<\/p>\n\n\n\n<p><strong>B\u01b0\u1edbc 1:<\/strong> Nh\u1eadp th\u01b0 vi\u1ec7n NumPy:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np<\/code><\/pre>\n\n\n\n<p><strong>B\u01b0\u1edbc 2: <\/strong>T\u1ea1o m\u1ea3ng \u0111i\u1ec3m s\u1ed1 c\u1ee7a sinh vi\u00ean:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>diem_sinh_vien = np.array(&#091;8, 7, 9, 6, 8.5, 9.5, 7.5, 6.5, 8, 9])<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"750\" height=\"425\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-7.webp\" alt=\"bai-toan-don-gian-su-dung-thu-vien-numpy\" class=\"wp-image-82760\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-7.webp 750w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2023\/12\/numpy-la-gi-7-300x170.webp 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><figcaption class=\"wp-element-caption\"><strong>B\u00e0i to\u00e1n \u0111\u01a1n gi\u1ea3n s\u1eed d\u1ee5ng th\u01b0 vi\u1ec7n NumPy<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p><strong>B\u01b0\u1edbc 3:<\/strong> T\u00ednh \u0111i\u1ec3m trung b\u00ecnh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>diem_trung_binh = np.mean(diem_sinh_vien)<\/code><\/pre>\n\n\n\n<p>K\u1ebft qu\u1ea3:<\/p>\n\n\n\n<p>\u0110i\u1ec3m trung b\u00ecnh c\u1ee7a l\u1edbp l\u00e0: 8.0<\/p>\n\n\n\n<p><strong>B\u01b0\u1edbc 4:<\/strong> In k\u1ebft qu\u1ea3<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(\"\u0110i\u1ec3m trung b\u00ecnh c\u1ee7a l\u1edbp l\u00e0:\", diem_trung_binh)<\/code><\/pre>\n\n\n\n<p>T\u00f3m l\u1ea1i, NumPy kh\u00f4ng ch\u1ec9 gi\u00fap ch\u00fang ta gi\u1ea3i quy\u1ebft c\u00e1c b\u00e0i to\u00e1n khoa h\u1ecdc d\u1eef li\u1ec7u m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng m\u00e0 c\u00f2n l\u00e0 ch\u00eca kh\u00f3a m\u1edf c\u00e1nh c\u1eeda cho nh\u1eefng kh\u00e1m ph\u00e1 s\u00e2u h\u01a1n v\u1ec1 th\u1ebf gi\u1edbi c\u1ee7a x\u1eed l\u00fd s\u1ed1 li\u1ec7u. N\u1ebfu b\u1ea1n l\u00e0 m\u1ed9t ng\u01b0\u1eddi l\u1eadp tr\u00ecnh Python, NumPy s\u1ebd l\u00e0 m\u1ed9t ng\u01b0\u1eddi b\u1ea1n \u0111\u1ed3ng h\u00e0nh \u0111\u00e1ng tin c\u1eady trong c\u00f4ng vi\u1ec7c c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<h2 id=\"Nh\u1eefng_c\u00e2u_h\u1ecfi_th\u01b0\u1eddng_g\u1eb7p\"><a id=\"post-82724-_gl1o53hw41py\"><\/a><strong>Nh\u1eefng c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p<\/strong><\/h2>\n\n\n\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"NumPy_ra_\u0111\u1eddi_khi_n\u00e0o?\">NumPy ra \u0111\u1eddi khi n\u00e0o?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>N\u0103m 2005, Travis Oliphant (m\u1ed9t trong nh\u1eefng nh\u00e0 ph\u00e1t tri\u1ec3n c\u1ee7a NumPy) \u0111\u00e3 chuy\u1ec3n c\u00e1c ch\u1ee9c n\u0103ng c\u1ee7a Numarray (m\u1ed9t \u0111\u1ed1i th\u1ee7 c\u1ee7a Numeric) sang Numeric. Phi\u00ean b\u1ea3n NumPy 1.0 \u0111\u01b0\u1ee3c ph\u00e1t h\u00e0nh v\u00e0o n\u0103m 2006.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"L\u00e0m_th\u1ebf_n\u00e0o_\u0111\u1ec3_c\u00e0i_\u0111\u1eb7t_NumPy_trong_Python?\">L\u00e0m th\u1ebf n\u00e0o \u0111\u1ec3 c\u00e0i \u0111\u1eb7t NumPy trong Python?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t NumPy b\u1eb1ng l\u1ec7nh pip trong Command Prompt ho\u1eb7c Terminal b\u1eb1ng c\u00e2u l\u1ec7nh:<\/p>\n\n\n\n<p><em>pip install numpy<\/em><\/p>\n\n\n\n<p><em>pip install numpy<\/em><\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"T\u1ea1i_sao_NumPy_l\u00e0_l\u1ef1a_ch\u1ecdn_t\u1ed1i_\u01b0u_cho_Python?\">T\u1ea1i sao NumPy l\u00e0 l\u1ef1a ch\u1ecdn t\u1ed1i \u01b0u cho Python?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>NumPy \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong Python v\u00ec c\u00f3 th\u1ec3 gi\u00fap c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t x\u1eed l\u00fd d\u1eef li\u1ec7u s\u1ed1 so v\u1edbi vi\u1ec7c s\u1eed d\u1ee5ng danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng. Trong Python, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng danh s\u00e1ch nh\u01b0ng ch\u00fang s\u1ebd b\u1ecb ch\u1eadm h\u01a1n trong qu\u00e1 tr\u00ecnh x\u1eed l\u00fd d\u1eef li\u1ec7u l\u1edbn. NumPy \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf \u0111\u1ec3 cung c\u1ea5p m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng m\u1ea3ng nhanh h\u01a1n l\u00ean \u0111\u1ebfn 50 l\u1ea7n so v\u1edbi danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng.<\/p>\n\n\n\n<p>Ngo\u00e0i ra, NumPy c\u00f2n c\u00f3 kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng Python b\u1eb1ng c\u00e1ch cung c\u1ea5p c\u00e1c c\u1ea5u tr\u00fac d\u1eef li\u1ec7u ph\u00e2n t\u00edch ti\u00ean ti\u1ebfn, \u0111\u1ea3m b\u1ea3o t\u00ednh nhanh ch\u00f3ng khi thao t\u00e1c v\u1edbi m\u1ea3ng v\u00e0 ma tr\u1eadn.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"C\u00f3_nh\u1eefng_l\u1ef1a_ch\u1ecdn_n\u00e0o_c\u00f3_th\u1ec3_thay_th\u1ebf_NumPy?\">C\u00f3 nh\u1eefng l\u1ef1a ch\u1ecdn n\u00e0o c\u00f3 th\u1ec3 thay th\u1ebf NumPy?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>N\u1ebfu mu\u1ed1n t\u00ecm ki\u1ebfm c\u00e1c th\u01b0 vi\u1ec7n thay th\u1ebf ho\u1eb7c b\u1ed5 sung cho NumPy, b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o: Pandas, <a href=\"https:\/\/tino.vn\/blog\/tensorflow-la-gi\/\" target=\"_blank\" data-type=\"post\" data-id=\"28231\" rel=\"noreferrer noopener\">TensorFlow<\/a> v\u00e0<a href=\"https:\/\/tino.vn\/blog\/pytorch-la-gi\/\" target=\"_blank\" data-type=\"post\" data-id=\"60791\" rel=\"noreferrer noopener\"> PyTorch<\/a>, Dask, CuPy, Blaze,.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"NumPy ra \u0111\u1eddi khi n\u00e0o?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>N\u0103m 2005, Travis Oliphant (m\u1ed9t trong nh\u1eefng nh\u00e0 ph\u00e1t tri\u1ec3n c\u1ee7a NumPy) \u0111\u00e3 chuy\u1ec3n c\u00e1c ch\u1ee9c n\u0103ng c\u1ee7a Numarray (m\u1ed9t \u0111\u1ed1i th\u1ee7 c\u1ee7a Numeric) sang Numeric. Phi\u00ean b\u1ea3n NumPy 1.0 \u0111\u01b0\u1ee3c ph\u00e1t h\u00e0nh v\u00e0o n\u0103m 2006.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"L\u00e0m th\u1ebf n\u00e0o \u0111\u1ec3 c\u00e0i \u0111\u1eb7t NumPy trong Python?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>B\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t NumPy b\u1eb1ng l\u1ec7nh pip trong Command Prompt ho\u1eb7c Terminal b\u1eb1ng c\u00e2u l\u1ec7nh:<\/p><p><em>pip install numpy<\/em><\/p><p><em>pip install numpy<\/em><\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"T\u1ea1i sao NumPy l\u00e0 l\u1ef1a ch\u1ecdn t\u1ed1i \u01b0u cho Python?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>NumPy \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong Python v\u00ec c\u00f3 th\u1ec3 gi\u00fap c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t x\u1eed l\u00fd d\u1eef li\u1ec7u s\u1ed1 so v\u1edbi vi\u1ec7c s\u1eed d\u1ee5ng danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng. Trong Python, ch\u00fang ta c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng danh s\u00e1ch nh\u01b0ng ch\u00fang s\u1ebd b\u1ecb ch\u1eadm h\u01a1n trong qu\u00e1 tr\u00ecnh x\u1eed l\u00fd d\u1eef li\u1ec7u l\u1edbn. NumPy \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf \u0111\u1ec3 cung c\u1ea5p m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng m\u1ea3ng nhanh h\u01a1n l\u00ean \u0111\u1ebfn 50 l\u1ea7n so v\u1edbi danh s\u00e1ch th\u00f4ng th\u01b0\u1eddng.<\/p><p>Ngo\u00e0i ra, NumPy c\u00f2n c\u00f3 kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng Python b\u1eb1ng c\u00e1ch cung c\u1ea5p c\u00e1c c\u1ea5u tr\u00fac d\u1eef li\u1ec7u ph\u00e2n t\u00edch ti\u00ean ti\u1ebfn, \u0111\u1ea3m b\u1ea3o t\u00ednh nhanh ch\u00f3ng khi thao t\u00e1c v\u1edbi m\u1ea3ng v\u00e0 ma tr\u1eadn.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"C\u00f3 nh\u1eefng l\u1ef1a ch\u1ecdn n\u00e0o c\u00f3 th\u1ec3 thay th\u1ebf NumPy?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>N\u1ebfu mu\u1ed1n t\u00ecm ki\u1ebfm c\u00e1c th\u01b0 vi\u1ec7n thay th\u1ebf ho\u1eb7c b\u1ed5 sung cho NumPy, b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o: Pandas, <a>TensorFlow<\/a> v\u00e0<a> PyTorch<\/a>, Dask, CuPy, Blaze,.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Khi b\u1eaft \u0111\u1ea7u kh\u00e1m ph\u00e1 s\u00e2u h\u01a1n v\u00e0o th\u1ebf gi\u1edbi phong ph\u00fa c\u1ee7a l\u1eadp tr\u00ecnh Python, b\u1ea1n kh\u00f4ng th\u1ec3 b\u1ecf qua m\u1ed9t c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd m\u00e0 h\u1ea7u h\u1ebft c\u00e1c nh\u00e0 khoa h\u1ecdc d\u1eef li\u1ec7u v\u00e0 nh\u00e0 nghi\u00ean c\u1ee9u s\u1eed d\u1ee5ng. \u0110\u00f3 l\u00e0 NumPy. V\u1eady c\u1ee5 th\u1ec3 NumPy l\u00e0 g\u00ec? C\u00e1c b\u1ea1n h\u00e3y c\u00f9ng TinoHost [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":82763,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-82724","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/82724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=82724"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/82724\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/82763"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=82724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/categories?post=82724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=82724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}