{"id":1782,"date":"2023-07-25T00:34:00","date_gmt":"2023-07-25T00:34:00","guid":{"rendered":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/"},"modified":"2023-07-25T00:34:00","modified_gmt":"2023-07-25T00:34:00","slug":"importa-numpy-come-np","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/","title":{"rendered":"Il modo pi\u00f9 semplice per utilizzare numpy: importa numpy come np"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\"><b>NumPy<\/b> , che sta per Numerical Python, \u00e8 una libreria di calcolo scientifico costruita sul linguaggio di programmazione Python.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il modo pi\u00f9 comune per importare NumPy nel tuo ambiente Python \u00e8 utilizzare la seguente sintassi:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> numpy <span style=\"color: #107d3f;\">as<\/span> np\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">La parte <strong>import numpy<\/strong> del codice indica a Python di integrare la libreria NumPy nel tuo ambiente attuale.<\/span><\/p>\n<p> <span style=\"color: #000000;\">La parte <strong>as np<\/strong> del codice dice quindi a Python di dare a NumPy l&#8217;alias di <strong>np<\/strong> . Ci\u00f2 ti consente di utilizzare le funzioni NumPy semplicemente digitando np.function_name anzich\u00e9 numpy.function_name.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dopo aver importato NumPy, puoi utilizzare le funzioni integrate per creare e analizzare rapidamente i dati.<\/span><\/p>\n<h3> <strong><span style=\"color: #000000;\">Come creare un array NumPy di base<\/span><\/strong><\/h3>\n<p> <span style=\"color: #000000;\">Il tipo di dati pi\u00f9 comune con cui lavorerai in NumPy \u00e8 l&#8217; <strong>array<\/strong> , che pu\u00f2 essere creato utilizzando la funzione <strong>np.array()<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Il codice seguente mostra come creare un array NumPy unidimensionale di base:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n<\/span>\n#define array<\/span>\nx = np. <span style=\"color: #3366ff;\">array<\/span> ([1, 12, 14, 9, 5])\n\n<span style=\"color: #008080;\">#display array<\/span>\n<span style=\"color: #008000;\">print<\/span> (x)\n\n[1 12 14 9 5]\n\n<span style=\"color: #008080;\">#display number of elements in array<\/span>\nx. <span style=\"color: #3366ff;\">size<\/span>\n\n5<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Puoi anche creare pi\u00f9 tabelle ed eseguire operazioni su di esse come addizione, sottrazione, moltiplicazione, ecc.<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np \n\n<span style=\"color: #008080;\">#define arrays<\/span><\/span>\n<span style=\"color: #000000;\">x = np. <span style=\"color: #3366ff;\">array<\/span> ([1, 12, 14, 9, 5])\ny = np. <span style=\"color: #3366ff;\">array<\/span> ([2, 3, 3, 4, 2])\n\n<\/span><span style=\"color: #008080;\">#add the two arrays<\/span>\nx+y\n\narray([ 3, 15, 17, 13, 7])\n\n<span style=\"color: #008080;\">#subtract the two arrays<\/span>\nxy\n\narray([-1, 9, 11, 5, 3])\n\n<span style=\"color: #008080;\">#multiply the two arrays<\/span>\nx*y\n\narray([ 2, 36, 42, 36, 10])\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Consulta <a href=\"https:\/\/numpy.org\/doc\/stable\/user\/absolute_beginners.html\" target=\"_blank\" rel=\"noopener\">la Guida per principianti assoluti a NumPy<\/a> per un&#8217;introduzione dettagliata a tutte le funzioni di base di NumPy.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Potenziali errori durante l&#8217;importazione di NumPy<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Un potenziale errore che potresti riscontrare durante l&#8217;importazione di NumPy \u00e8:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #ff0000;\">NameError<\/span> : name 'np' is not defined\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Ci\u00f2 accade quando non si riesce a creare l&#8217;alias NumPy durante l&#8217;importazione. Leggi <a href=\"https:\/\/statorials.org\/it\/nome-errore-nome-np-non-definito\/\" target=\"_blank\" rel=\"noopener\">questo tutorial<\/a> per scoprire come correggere rapidamente questo errore.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Se vuoi saperne di pi\u00f9 su NumPy, consulta le seguenti risorse:<\/span><\/p>\n<p> Elenco completo delle guide statistiche Python<br \/> <a href=\"https:\/\/numpy.org\/\" target=\"_blank\" rel=\"noopener\">Pagina della documentazione di NumPy online<\/a><br \/> <a href=\"https:\/\/twitter.com\/numpy_team?lang=en\" target=\"_blank\" rel=\"noopener\">Pagina Twitter ufficiale di NumPy<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NumPy , che sta per Numerical Python, \u00e8 una libreria di calcolo scientifico costruita sul linguaggio di programmazione Python. Il modo pi\u00f9 comune per importare NumPy nel tuo ambiente Python \u00e8 utilizzare la seguente sintassi: import numpy as np La parte import numpy del codice indica a Python di integrare la libreria NumPy nel tuo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-25T00:34:00+00:00\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/\",\"url\":\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/\",\"name\":\"Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-25T00:34:00+00:00\",\"dateModified\":\"2023-07-25T00:34:00+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/importa-numpy-come-np\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Il modo pi\u00f9 semplice per utilizzare numpy: importa numpy come np\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np","description":"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/","og_locale":"it_IT","og_type":"article","og_title":"Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np","og_description":"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.","og_url":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/","og_site_name":"Statorials","article_published_time":"2023-07-25T00:34:00+00:00","author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"2 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/","url":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/","name":"Il modo pi\u00f9 semplice per utilizzare NumPy: importa numpy come np","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-25T00:34:00+00:00","dateModified":"2023-07-25T00:34:00+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega il modo pi\u00f9 semplice e comune per importare la libreria NumPy in Python: importare numpy come np.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/importa-numpy-come-np\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/importa-numpy-come-np\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Il modo pi\u00f9 semplice per utilizzare numpy: importa numpy come np"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1782"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=1782"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/1782\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=1782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=1782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=1782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}