{"id":146,"date":"2023-08-15T21:26:28","date_gmt":"2023-08-15T18:26:28","guid":{"rendered":"https:\/\/www.facadium.com.tr\/blog\/?p=146"},"modified":"2023-08-31T17:02:43","modified_gmt":"2023-08-31T14:02:43","slug":"pandas-ile-veri-okuma","status":"publish","type":"post","link":"https:\/\/www.facadium.com.tr\/blog\/pandas-ile-veri-okuma\/","title":{"rendered":"Pandas ile Veri Okuma"},"content":{"rendered":"\n<p>Bu yaz\u0131, size&nbsp;<strong>Pandas ile Veri Okuma<\/strong>&nbsp;hakk\u0131nda bilgi verecektir.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Pandas ile veri okuma ve yazma i\u015flemleri olduk\u00e7a \u00f6nemlidir ve s\u0131kl\u0131kla kullan\u0131l\u0131r. Pandas, bir\u00e7ok veri kayna\u011f\u0131ndan veri okuma ve yazma i\u00e7in y\u00f6ntemler sa\u011flar. Bu makalede, pandas ile veri okuma ve yazma i\u015flemleri hakk\u0131nda ayr\u0131nt\u0131l\u0131 bilgi verece\u011fiz.<\/p>\n\n\n\n<p><strong>Veri Okuma<\/strong><\/p>\n\n\n\n<p>Pandas, bir\u00e7ok veri kayna\u011f\u0131ndan veri okumay\u0131 destekler. \u0130\u015fte pandas ile veri okuma i\u00e7in kullanabilece\u011finiz baz\u0131 y\u00f6ntemler:<\/p>\n\n\n\n<p><strong>CSV Dosyalar\u0131ndan Okuma<\/strong><\/p>\n\n\n\n<p>CSV (comma-separated values) dosyalar\u0131, s\u00fctunlar aras\u0131na virg\u00fcl konulmu\u015f bir d\u00fcz metin dosyas\u0131d\u0131r ve pandas taraf\u0131ndan kolayca okunabilir.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\n# CSV dosyas\u0131ndan veri okuma\ndf = pd.read_csv('data.csv')\n\n# \u0130lk 5 sat\u0131r\u0131 g\u00f6r\u00fcnt\u00fcleme\nprint(df.head())<\/code><\/pre>\n\n\n\n<p><strong>Excel Dosyalar\u0131ndan Okuma<\/strong><\/p>\n\n\n\n<p>Pandas, Excel dosyalar\u0131n\u0131 okumak i\u00e7in read_excel() fonksiyonunu sa\u011flar.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\n# Excel dosyas\u0131ndan veri okuma\ndf = pd.read_excel('data.xlsx')\n\n# \u0130lk 5 sat\u0131r\u0131 g\u00f6r\u00fcnt\u00fcleme\nprint(df.head())<\/code><\/pre>\n\n\n\n<p><strong>SQL Veritaban\u0131ndan Okuma<\/strong><\/p>\n\n\n\n<p>Pandas, SQL veritabanlar\u0131ndan veri okumak i\u00e7in read_sql() fonksiyonunu sa\u011flar.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\nimport sqlite3\n\n# Veritaban\u0131 ba\u011flant\u0131s\u0131 olu\u015fturma\nconn = sqlite3.connect('mydatabase.db')\n\n# SQL sorgusu\nquery = \"SELECT * FROM mytable\"\n\n# SQL veritaban\u0131ndan veri okuma\ndf = pd.read_sql(query, conn)\n\n# \u0130lk 5 sat\u0131r\u0131 g\u00f6r\u00fcnt\u00fcleme\nprint(df.head())<\/code><\/pre>\n\n\n\n<p><strong>JSON Dosyalar\u0131ndan Okuma<\/strong><\/p>\n\n\n\n<p>Pandas, JSON dosyalar\u0131n\u0131 okumak i\u00e7in read_json() fonksiyonunu sa\u011flar.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\n<em># JSON dosyas\u0131ndan veri okuma<\/em>\ndf = pd.read_json('data.json')\n\n<em># \u0130lk 5 sat\u0131r\u0131 g\u00f6r\u00fcnt\u00fcleme<\/em>\nprint(df.head())<\/code><\/pre>\n\n\n\n<p><strong>Veri Yazma<\/strong><\/p>\n\n\n\n<p>Pandas, verileri CSV, Excel, SQL veritabanlar\u0131 ve JSON dosyalar\u0131 gibi bir\u00e7ok farkl\u0131 formatta yazman\u0131za olanak sa\u011flar. \u0130\u015fte pandas ile veri yazmak i\u00e7in kullanabilece\u011finiz baz\u0131 y\u00f6ntemler:<\/p>\n\n\n\n<p><strong>CSV Dosyalar\u0131na Yazma<\/strong><\/p>\n\n\n\n<p>CSV dosyalar\u0131na veri yazmak i\u00e7in, to_csv() fonksiyonunu kullanabilirsiniz.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\n# CSV dosyas\u0131na veri yazma\ndf.to_csv('data.csv', index=False)<\/code><\/pre>\n\n\n\n<p><strong>Excel Dosyalar\u0131na Yazma<\/strong><\/p>\n\n\n\n<p>Excel dosyalar\u0131na veri yazmak i\u00e7in, to_excel() fonksiyonunu kullanabilirsiniz.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd\n\n# Excel dosyas\u0131na veri yazma\ndf.to_excel('data.xlsx', index=False)<\/code><\/pre>\n\n\n\n<p><strong>SQL Veritaban\u0131na Yazma<\/strong><\/p>\n\n\n\n<p>SQL veritaban\u0131na veri yazmak i\u00e7in, pandas to_sql() fonksiyonunu kullanabilir<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bu yaz\u0131, size&nbsp;Pandas ile Veri Okuma&nbsp;hakk\u0131nda bilgi verecektir. Pandas ile veri okuma ve yazma i\u015flemleri olduk\u00e7a \u00f6nemlidir ve s\u0131kl\u0131kla kullan\u0131l\u0131r. Pandas, bir\u00e7ok veri kayna\u011f\u0131ndan veri [&#8230;]<\/p>\n","protected":false},"author":3,"featured_media":443,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35,5],"tags":[32,31,34,36,8,29,33,30,9],"class_list":["post-146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pandas","category-python","tag-data-analysis","tag-data-mining","tag-data-science","tag-pandas","tag-python","tag-veri-analizi","tag-veri-bilimi","tag-veri-madenciligi","tag-yazilim"],"_links":{"self":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":2,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":165,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions\/165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/media\/443"}],"wp:attachment":[{"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.facadium.com.tr\/blog\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}