{"id":141,"date":"2017-12-29T10:34:49","date_gmt":"2017-12-29T10:34:49","guid":{"rendered":"http:\/\/fcpython.com\/?p=141"},"modified":"2020-12-18T20:10:10","modified_gmt":"2020-12-18T20:10:10","slug":"series","status":"publish","type":"post","link":"https:\/\/fcpython.com\/data-analysis\/series","title":{"rendered":"Series"},"content":{"rendered":"<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\">\n<\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>If you have just taken a look at NumPy&#8217;s arrays, then Pandas&#8217; series will be really easy to pick up.<\/p>\n<p>The key difference between these two data types is that series allow us to label our axes, making our grids a lot easier to read, index and utilise.<\/p>\n<p>Let&#8217;s fire up NumPy and Pandas and create some series. Remember to install these modules if you haven&#8217;t already.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[1]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span><\/span><span class=\"kn\">import<\/span> <span class=\"nn\">numpy<\/span> <span class=\"k\">as<\/span> <span class=\"nn\">np<\/span>\r\n<span class=\"kn\">import<\/span> <span class=\"nn\">pandas<\/span> <span class=\"k\">as<\/span> <span class=\"nn\">pd<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[2]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span><\/span><span class=\"n\">Capacity<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pd<\/span><span class=\"o\">.<\/span><span class=\"n\">Series<\/span><span class=\"p\">(<\/span><span class=\"n\">data<\/span><span class=\"o\">=<\/span><span class=\"p\">[<\/span><span class=\"mi\">60432<\/span><span class=\"p\">,<\/span><span class=\"mi\">55097<\/span><span class=\"p\">,<\/span><span class=\"mi\">39460<\/span><span class=\"p\">])<\/span>\r\n<span class=\"n\">Capacity<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[2]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>0    60432\r\n1    55097\r\n2    39460\r\ndtype: int64<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\">\n<\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>So there we have our first series, created from a list of [100,200,300]. You&#8217;ll notice that this looks quite different from our previous lists and arrays because we have an index running alongside it.<\/p>\n<p>What is really cool about series, is that they allow us to change these index labels:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[3]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span><\/span><span class=\"n\">Capacity<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pd<\/span><span class=\"o\">.<\/span><span class=\"n\">Series<\/span><span class=\"p\">(<\/span><span class=\"n\">data<\/span><span class=\"o\">=<\/span><span class=\"p\">[<\/span><span class=\"mi\">60432<\/span><span class=\"p\">,<\/span><span class=\"mi\">55097<\/span><span class=\"p\">,<\/span><span class=\"mi\">39460<\/span><span class=\"p\">],<\/span>\r\n                     <span class=\"n\">index<\/span><span class=\"o\">=<\/span><span class=\"p\">[<\/span><span class=\"s2\">&quot;Emirates Stadium&quot;<\/span><span class=\"p\">,<\/span><span class=\"s2\">&quot;Etihad Stadium&quot;<\/span><span class=\"p\">,<\/span><span class=\"s2\">&quot;Elland Road&quot;<\/span><span class=\"p\">])<\/span>\r\n<span class=\"n\">Capacity<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[3]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>Emirates Stadium    60432\r\nEtihad Stadium      55097\r\nElland Road         39460\r\ndtype: int64<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\">\n<\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Passing an index argument changes the index labels &#8211; our data is now so much easier to read when we need to. Easier to select, too:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[4]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span><\/span><span class=\"n\">Capacity<\/span><span class=\"p\">[<\/span><span class=\"s2\">&quot;Elland Road&quot;<\/span><span class=\"p\">]<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[4]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>39460<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\">\n<\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>In this example, our stadium capacities and labels were in two separate lists. We can do the same thing with a dictionary:<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In&nbsp;[5]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\" highlight hl-ipython3\">\n<pre><span><\/span><span class=\"n\">CapacityDict<\/span> <span class=\"o\">=<\/span> <span class=\"p\">{<\/span><span class=\"s1\">&#39;Ewood Park&#39;<\/span><span class=\"p\">:<\/span><span class=\"mi\">31367<\/span><span class=\"p\">,<\/span>\r\n                <span class=\"s1\">&#39;Liberty Stadium&#39;<\/span><span class=\"p\">:<\/span><span class=\"mi\">20937<\/span><span class=\"p\">,<\/span>\r\n                <span class=\"s1\">&#39;Portman Road&#39;<\/span><span class=\"p\">:<\/span><span class=\"mi\">30311<\/span><span class=\"p\">}<\/span>\r\n\r\n<span class=\"n\">Capacity<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pd<\/span><span class=\"o\">.<\/span><span class=\"n\">Series<\/span><span class=\"p\">(<\/span><span class=\"n\">CapacityDict<\/span><span class=\"p\">)<\/span>\r\n<span class=\"n\">Capacity<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[5]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>Ewood Park         31367\r\nLiberty Stadium    20937\r\nPortman Road       30311\r\ndtype: int64<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"prompt input_prompt\">\n<\/div>\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"Summary\">Summary<\/h3>\n<p>Told you series would be easy to understand. A simple concept, but one that makes our data a bit more comfortable to use &#8211; we can now understand data by labels, not just index numbers.<\/p>\n<p>Pandas&#8217; data frame builds on this further to create labelled grids. Once we understand these we can really get started with data analysis in Python.<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you have just taken a look at NumPy&#8217;s arrays, then Pandas&#8217; series will be really easy to pick up. The key difference between&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[17],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v19.13 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Series - FC Python<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fcpython.com\/data-analysis\/series\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Series - FC Python\" \/>\n<meta property=\"og:description\" content=\"If you have just taken a look at NumPy&#8217;s arrays, then Pandas&#8217; series will be really easy to pick up. The key difference between&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fcpython.com\/data-analysis\/series\" \/>\n<meta property=\"og:site_name\" content=\"FC Python\" \/>\n<meta property=\"article:published_time\" content=\"2017-12-29T10:34:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-18T20:10:10+00:00\" \/>\n<meta name=\"author\" content=\"FCPythonADMIN\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@FC__Python\" \/>\n<meta name=\"twitter:site\" content=\"@FC__Python\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"FCPythonADMIN\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series#article\",\"isPartOf\":{\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series\"},\"author\":{\"name\":\"FCPythonADMIN\",\"@id\":\"https:\/\/fcpython.com\/#\/schema\/person\/ed81e5728929acd0f3f2d9bf824a0bd0\"},\"headline\":\"Series\",\"datePublished\":\"2017-12-29T10:34:49+00:00\",\"dateModified\":\"2020-12-18T20:10:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series\"},\"wordCount\":244,\"publisher\":{\"@id\":\"https:\/\/fcpython.com\/#organization\"},\"keywords\":[\"Pandas\"],\"articleSection\":[\"Data Analysis\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series\",\"url\":\"https:\/\/fcpython.com\/data-analysis\/series\",\"name\":\"Series - FC Python\",\"isPartOf\":{\"@id\":\"https:\/\/fcpython.com\/#website\"},\"datePublished\":\"2017-12-29T10:34:49+00:00\",\"dateModified\":\"2020-12-18T20:10:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fcpython.com\/data-analysis\/series\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fcpython.com\/data-analysis\/series#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fcpython.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Series\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fcpython.com\/#website\",\"url\":\"https:\/\/fcpython.com\/\",\"name\":\"FC Python\",\"description\":\"Learning Python through football\",\"publisher\":{\"@id\":\"https:\/\/fcpython.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fcpython.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fcpython.com\/#organization\",\"name\":\"FC Python\",\"url\":\"https:\/\/fcpython.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/fcpython.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fcpython.com\/wp-content\/uploads\/2017\/12\/Logocomp9.png\",\"contentUrl\":\"https:\/\/fcpython.com\/wp-content\/uploads\/2017\/12\/Logocomp9.png\",\"width\":981,\"height\":1049,\"caption\":\"FC Python\"},\"image\":{\"@id\":\"https:\/\/fcpython.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/FC__Python\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/fcpython.com\/#\/schema\/person\/ed81e5728929acd0f3f2d9bf824a0bd0\",\"name\":\"FCPythonADMIN\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/fcpython.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7a172a6f730270fc0f8bb1a8ff958895?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7a172a6f730270fc0f8bb1a8ff958895?s=96&d=mm&r=g\",\"caption\":\"FCPythonADMIN\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Series - FC Python","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:\/\/fcpython.com\/data-analysis\/series","og_locale":"en_GB","og_type":"article","og_title":"Series - FC Python","og_description":"If you have just taken a look at NumPy&#8217;s arrays, then Pandas&#8217; series will be really easy to pick up. The key difference between&hellip;","og_url":"https:\/\/fcpython.com\/data-analysis\/series","og_site_name":"FC Python","article_published_time":"2017-12-29T10:34:49+00:00","article_modified_time":"2020-12-18T20:10:10+00:00","author":"FCPythonADMIN","twitter_card":"summary_large_image","twitter_creator":"@FC__Python","twitter_site":"@FC__Python","twitter_misc":{"Written by":"FCPythonADMIN","Estimated reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fcpython.com\/data-analysis\/series#article","isPartOf":{"@id":"https:\/\/fcpython.com\/data-analysis\/series"},"author":{"name":"FCPythonADMIN","@id":"https:\/\/fcpython.com\/#\/schema\/person\/ed81e5728929acd0f3f2d9bf824a0bd0"},"headline":"Series","datePublished":"2017-12-29T10:34:49+00:00","dateModified":"2020-12-18T20:10:10+00:00","mainEntityOfPage":{"@id":"https:\/\/fcpython.com\/data-analysis\/series"},"wordCount":244,"publisher":{"@id":"https:\/\/fcpython.com\/#organization"},"keywords":["Pandas"],"articleSection":["Data Analysis"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/fcpython.com\/data-analysis\/series","url":"https:\/\/fcpython.com\/data-analysis\/series","name":"Series - FC Python","isPartOf":{"@id":"https:\/\/fcpython.com\/#website"},"datePublished":"2017-12-29T10:34:49+00:00","dateModified":"2020-12-18T20:10:10+00:00","breadcrumb":{"@id":"https:\/\/fcpython.com\/data-analysis\/series#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fcpython.com\/data-analysis\/series"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/fcpython.com\/data-analysis\/series#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fcpython.com\/"},{"@type":"ListItem","position":2,"name":"Series"}]},{"@type":"WebSite","@id":"https:\/\/fcpython.com\/#website","url":"https:\/\/fcpython.com\/","name":"FC Python","description":"Learning Python through football","publisher":{"@id":"https:\/\/fcpython.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fcpython.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/fcpython.com\/#organization","name":"FC Python","url":"https:\/\/fcpython.com\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/fcpython.com\/#\/schema\/logo\/image\/","url":"https:\/\/fcpython.com\/wp-content\/uploads\/2017\/12\/Logocomp9.png","contentUrl":"https:\/\/fcpython.com\/wp-content\/uploads\/2017\/12\/Logocomp9.png","width":981,"height":1049,"caption":"FC Python"},"image":{"@id":"https:\/\/fcpython.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/twitter.com\/FC__Python"]},{"@type":"Person","@id":"https:\/\/fcpython.com\/#\/schema\/person\/ed81e5728929acd0f3f2d9bf824a0bd0","name":"FCPythonADMIN","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/fcpython.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7a172a6f730270fc0f8bb1a8ff958895?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7a172a6f730270fc0f8bb1a8ff958895?s=96&d=mm&r=g","caption":"FCPythonADMIN"}}]}},"_links":{"self":[{"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/posts\/141"}],"collection":[{"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":1,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/posts\/141\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fcpython.com\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}