{"id":2455,"date":"2021-08-19T10:36:32","date_gmt":"2021-08-19T17:36:32","guid":{"rendered":"https:\/\/doubleecpu.com\/?page_id=2455"},"modified":"2021-08-19T14:57:10","modified_gmt":"2021-08-19T21:57:10","slug":"pandas","status":"publish","type":"page","link":"https:\/\/doubleecpu.com\/index.php\/pandas\/","title":{"rendered":"PANDAS"},"content":{"rendered":"<p><a href=\"https:\/\/pandas.pydata.org\/docs\/\">Documentation<\/a><\/p>\n\n\n<h2 class=\"wp-block-heading\">Using Pandas for data science<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Import Pandas Package\nimport pandas as pd\n\n#create a dataframe object using pandas.read_csv(\"FileName.csv\", sep=\",\") sep short for separator as comma. \ncalifornia_housing_dataframe = pd.read_csv(\"sample_data\/california_housing_train.csv\", sep=\",\")\n#  pandas.size returns the size or number of rows in the file\ncalifornia_housing_dataframe.size\n# pandas.head(10) prints the first 10 rows\ncalifornia_housing_dataframe.head(10)\n# pandas.hist(\"column_Name\") calls matplotlib to create a chart based on \"column_Name\"\ncalifornia_housing_dataframe.hist('housing_median_age')\n# Creates a new dataframe with the two columns \"column1\", \"column2\"\nchd_beds_pop = california_housing_dataframe[ ['column1', 'column2'] ]\n# creates a new dataframe with rows where column2 is greater than 100\nbig_pop = california_housing_dataframe.loc[california_housing_dataframe['column2'] > 100]\n# returns size\/number of rows\nbig_pop.size\n# adds column3 = average (column1 divided by column2)\nbig_pop['column3'] = big_pop.apply(lambda row: row.column1\/row.column2, axis=1)\n# <\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Documentation Using Pandas for data science # Import Pandas Package import pandas as pd #create a dataframe object using pandas.read_csv(&#8220;FileName.csv&#8221;, sep=&#8221;,&#8221;) sep short for separator as comma. california_housing_dataframe = pd.read_csv(&#8220;sample_data\/california_housing_train.csv&#8221;, sep=&#8221;,&#8221;) # pandas.size returns the size or number of rows in the file california_housing_dataframe.size # pandas.head(10) prints the first 10 rows california_housing_dataframe.head(10) # pandas.hist(&#8220;column_Name&#8221;) calls &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/doubleecpu.com\/index.php\/pandas\/\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;PANDAS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2455","page","type-page","status-publish","hentry"],"featured_media_urls":[],"_links":{"self":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/comments?post=2455"}],"version-history":[{"count":2,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2455\/revisions"}],"predecessor-version":[{"id":2459,"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/pages\/2455\/revisions\/2459"}],"wp:attachment":[{"href":"https:\/\/doubleecpu.com\/index.php\/wp-json\/wp\/v2\/media?parent=2455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}