{"id":2416,"date":"2023-07-22T09:12:25","date_gmt":"2023-07-22T09:12:25","guid":{"rendered":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/"},"modified":"2023-07-22T09:12:25","modified_gmt":"2023-07-22T09:12:25","slug":"yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir","status":"publish","type":"post","link":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/","title":{"rendered":"Nas\u0131l d\u00fczeltilir? yaln\u0131zca 1 boyutundaki diziler python skaler de\u011ferlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Python kullan\u0131rken kar\u015f\u0131la\u015fabilece\u011finiz bir hata:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #ff0000;\">TypeError<\/span> : only size-1 arrays can be converted to Python scalars\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Bu hata en s\u0131k, bir NumPy kayan nokta de\u011ferleri dizisini bir tamsay\u0131 de\u011ferleri dizisine d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in <strong>np.int() i\u015flevini<\/strong> kullanmaya \u00e7al\u0131\u015f\u0131rken ortaya \u00e7\u0131kar.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ancak bu i\u015flev, bir dizi de\u011fer yerine yaln\u0131zca tek bir de\u011feri kabul eder.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Bunun yerine, bir NumPy float de\u011ferleri dizisini bir tamsay\u0131 de\u011ferleri dizisine d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in <strong>x.astype(int)<\/strong> kullanmal\u0131s\u0131n\u0131z, \u00e7\u00fcnk\u00fc bu i\u015flev bir diziyi kabul etme yetene\u011fine sahiptir.<\/span><\/p>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki \u00f6rnekte bu hatan\u0131n pratikte nas\u0131l d\u00fczeltilece\u011fi g\u00f6sterilmektedir.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hata nas\u0131l yeniden olu\u015fturulur?<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki NumPy float de\u011ferleri dizisini olu\u015fturdu\u011fumuzu varsayal\u0131m:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> numpy <span style=\"color: #008000;\">as<\/span> np\n\n<span style=\"color: #008080;\">#create NumPy array of float values\n<span style=\"color: #000000;\">x = np. <span style=\"color: #3366ff;\">array<\/span> ([3, 4.5, 6, 7.7, 9.2, 10, 12, 14.1, 15])\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">\u015eimdi bu kayan nokta de\u011ferleri dizisini bir tam say\u0131 de\u011ferleri dizisine d\u00f6n\u00fc\u015ft\u00fcrmeye \u00e7al\u0131\u015ft\u0131\u011f\u0131m\u0131z\u0131 varsayal\u0131m:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#attempt to convert array to integer values\n<span style=\"color: #000000;\">n.p. <span style=\"color: #3366ff;\">int<\/span> (x)\n\n<span style=\"color: #ff0000;\">TypeError<\/span> : only size-1 arrays can be converted to Python scalars \n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Bir <strong>TypeError<\/strong> al\u0131yoruz \u00e7\u00fcnk\u00fc <strong>np.int()<\/strong> i\u015flevi bir de\u011fer dizisini de\u011fil yaln\u0131zca tek de\u011ferleri kabul ediyor.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Hata nas\u0131l d\u00fczeltilir?<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Bir NumPy float de\u011fer dizisini tamsay\u0131 de\u011ferlere d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in a\u015fa\u011f\u0131daki kodu kullanabiliriz:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#convert array of float values to integer values<\/span>\nx. <span style=\"color: #3366ff;\">astype<\/span> (int)<\/span>\n\n<span style=\"color: #000000;\">array([ 3, 4, 6, 7, 9, 10, 12, 14, 15])\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">De\u011fer dizisinin tam say\u0131lara d\u00f6n\u00fc\u015ft\u00fcr\u00fcld\u00fc\u011f\u00fcn\u00fc ve <strong>astype()<\/strong> i\u015flevinin bir de\u011fer dizisini i\u015fleyebildi\u011fi i\u00e7in herhangi bir hata almad\u0131\u011f\u0131m\u0131z\u0131 unutmay\u0131n.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Not<\/strong> : <strong>astype()<\/strong> i\u015flevine ili\u015fkin t\u00fcm belgeleri <a href=\"https:\/\/numpy.org\/doc\/stable\/reference\/generated\/numpy.ndarray.astype.html\" target=\"_blank\" rel=\"noopener\">burada<\/a> bulabilirsiniz.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Ek kaynaklar<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">A\u015fa\u011f\u0131daki e\u011fitimlerde Python&#8217;daki di\u011fer yayg\u0131n hatalar\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/tr\/pandalarin-anahtar-hatasi\/\" target=\"_blank\" rel=\"noopener\">Pandas&#8217;ta KeyError Nas\u0131l D\u00fczeltilir<\/a><br \/> <a href=\"https:\/\/statorials.org\/tr\/deger-hatasi-kayan-noktali-nani-tam-sayiya-donusturemiyor\/\" target=\"_blank\" rel=\"noopener\">Nas\u0131l d\u00fczeltilir? ValueError: float NaN int&#8217;ye d\u00f6n\u00fc\u015ft\u00fcr\u00fclemiyor<\/a><br \/> <a href=\"https:\/\/statorials.org\/tr\/islenenler-formlarla-yayinlanamadi\/\" target=\"_blank\" rel=\"noopener\">Nas\u0131l d\u00fczeltilir? ValueError: \u0130\u015flenenler \u015fekillerle yay\u0131nlanamad\u0131<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python kullan\u0131rken kar\u015f\u0131la\u015fabilece\u011finiz bir hata: TypeError : only size-1 arrays can be converted to Python scalars Bu hata en s\u0131k, bir NumPy kayan nokta de\u011ferleri dizisini bir tamsay\u0131 de\u011ferleri dizisine d\u00f6n\u00fc\u015ft\u00fcrmek i\u00e7in np.int() i\u015flevini kullanmaya \u00e7al\u0131\u015f\u0131rken ortaya \u00e7\u0131kar. Ancak bu i\u015flev, bir dizi de\u011fer yerine yaln\u0131zca tek bir de\u011feri kabul eder. Bunun yerine, bir NumPy [&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":[],"class_list":["post-2416","post","type-post","status-publish","format-standard","hentry","category-rehber"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials<\/title>\n<meta name=\"description\" content=\"Bu e\u011fitimde Python&#039;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.\" \/>\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\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/\" \/>\n<meta property=\"og:locale\" content=\"tr_TR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials\" \/>\n<meta property=\"og:description\" content=\"Bu e\u011fitimde Python&#039;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-22T09:12:25+00:00\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Yazan:\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tahmini okuma s\u00fcresi\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 dakika\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/\",\"url\":\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/\",\"name\":\"Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/tr\/#website\"},\"datePublished\":\"2023-07-22T09:12:25+00:00\",\"dateModified\":\"2023-07-22T09:12:25+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48\"},\"description\":\"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/#breadcrumb\"},\"inLanguage\":\"tr\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Ev\",\"item\":\"https:\/\/statorials.org\/tr\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nas\u0131l d\u00fczeltilir? yaln\u0131zca 1 boyutundaki diziler python skaler de\u011ferlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/tr\/#website\",\"url\":\"https:\/\/statorials.org\/tr\/\",\"name\":\"Statorials\",\"description\":\"\u0130statistik okuryazarl\u0131\u011f\u0131 rehberiniz!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/tr\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"tr\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"tr\",\"@id\":\"https:\/\/statorials.org\/tr\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Merhaba, ben Benjamin, emekli bir istatistik profes\u00f6r\u00fc ve Statorials \u00f6\u011fretmenine d\u00f6n\u00fc\u015ft\u00fcm. \u0130statistik alan\u0131ndaki kapsaml\u0131 deneyimim ve uzmanl\u0131\u011f\u0131mla, \u00f6\u011frencilerimi Statorials arac\u0131l\u0131\u011f\u0131yla g\u00fc\u00e7lendirmek i\u00e7in bilgilerimi payla\u015fmaya can at\u0131yorum. Daha fazlas\u0131n\u0131 bil\",\"sameAs\":[\"https:\/\/statorials.org\/tr\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials","description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.","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\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/","og_locale":"tr_TR","og_type":"article","og_title":"Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials","og_description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.","og_url":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/","og_site_name":"Statorials","article_published_time":"2023-07-22T09:12:25+00:00","author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Yazan:":"Dr.benjamin anderson","Tahmini okuma s\u00fcresi":"2 dakika"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/","url":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/","name":"Nas\u0131l d\u00fczeltilir: Yaln\u0131zca 1 boyutundaki diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/tr\/#website"},"datePublished":"2023-07-22T09:12:25+00:00","dateModified":"2023-07-22T09:12:25+00:00","author":{"@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48"},"description":"Bu e\u011fitimde Python&#39;da a\u015fa\u011f\u0131daki hatan\u0131n nas\u0131l d\u00fczeltilece\u011fi a\u00e7\u0131klanmaktad\u0131r: Yaln\u0131zca boyutu 1 olan diziler Python skalerlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir.","breadcrumb":{"@id":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/#breadcrumb"},"inLanguage":"tr","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/tr\/yalnizca-1-boyutundaki-diziler-python-skalerlerine-donusturulebilir\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Ev","item":"https:\/\/statorials.org\/tr\/"},{"@type":"ListItem","position":2,"name":"Nas\u0131l d\u00fczeltilir? yaln\u0131zca 1 boyutundaki diziler python skaler de\u011ferlerine d\u00f6n\u00fc\u015ft\u00fcr\u00fclebilir"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/tr\/#website","url":"https:\/\/statorials.org\/tr\/","name":"Statorials","description":"\u0130statistik okuryazarl\u0131\u011f\u0131 rehberiniz!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/tr\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"tr"},{"@type":"Person","@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/365dc158a39a7c8ae256355451e3de48","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"tr","@id":"https:\/\/statorials.org\/tr\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/tr\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Merhaba, ben Benjamin, emekli bir istatistik profes\u00f6r\u00fc ve Statorials \u00f6\u011fretmenine d\u00f6n\u00fc\u015ft\u00fcm. \u0130statistik alan\u0131ndaki kapsaml\u0131 deneyimim ve uzmanl\u0131\u011f\u0131mla, \u00f6\u011frencilerimi Statorials arac\u0131l\u0131\u011f\u0131yla g\u00fc\u00e7lendirmek i\u00e7in bilgilerimi payla\u015fmaya can at\u0131yorum. Daha fazlas\u0131n\u0131 bil","sameAs":["https:\/\/statorials.org\/tr"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts\/2416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/comments?post=2416"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/posts\/2416\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/media?parent=2416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/categories?post=2416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/tr\/wp-json\/wp\/v2\/tags?post=2416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}