{"id":218,"date":"2019-02-17T23:37:33","date_gmt":"2019-02-17T23:37:33","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/python\/?p=218"},"modified":"2019-03-02T03:57:00","modified_gmt":"2019-03-02T03:57:00","slug":"21-python-map-filter-reduce","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/","title":{"rendered":"Python &#8211; Map, Filter, Reduce"},"content":{"rendered":"<p>You can perform some kind of data analytics on sets of data in Python. This is made possible by certain functions and constructs.<\/p>\n<p>In this article we would cover the following<\/p>\n<ol>\n<li><a href=\"#t1\">map<\/a><\/li>\n<li><a href=\"#t1\">filter<\/a><\/li>\n<li><a href=\"#t1\">reduce<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3 id=\"t1\">1. map<\/h3>\n<p>Map allows you to apply an operation to each element of a sequence. You provide two inputs to map: the function to apply and the sequence.<\/p>\n<p>The output is a sequence of the results.<\/p>\n<p>For example, assuming you have a function that calculates the area of a circle. This function is given below.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">math<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">def<\/span> <span style=\"color: #0066bb; font-weight: bold;\">calculatearea<\/span>(radius):\r\n    <span style=\"color: #888888;\"># calculate area of a circle<\/span>\r\n    area <span style=\"color: #333333;\">=<\/span> math<span style=\"color: #333333;\">.<\/span>pi <span style=\"color: #333333;\">*<\/span> radius <span style=\"color: #333333;\">*<\/span> radius\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> area\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Also, let&#8217;s say we have a list of radii as:<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">radii <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: bold;\">4<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">5.2<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">9<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">3<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">8<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">6<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">7.5<\/span>]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>To calculate the areas of circle with these radii, we can loop through the list of radii and call the calculatearea() function for each of the radii.<\/p>\n<p>The code to do this is show below.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">areas <span style=\"color: #333333;\">=<\/span> []\r\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> radius <span style=\"color: #000000; font-weight: bold;\">in<\/span> radii:\r\n    area <span style=\"color: #333333;\">=<\/span> calculatearea(radius)\r\n    areas<span style=\"color: #333333;\">.<\/span>append(area)\r\n\r\n<span style=\"color: #007020;\">print<\/span>(areas)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>This method above is fine and good. However, we can do the same thing with a single line of code. In this case, we use the map function.<\/p>\n<p>To do that, you simply call the map function, and provide the name of the function followed by the list of radii. This is shown below:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">areas <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">map<\/span>(calculatearea, radii)\r\n\r\n<span style=\"color: #007020;\">print<\/span>(<span style=\"color: #007020;\">list<\/span>(areas))\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>You will notice that in the second line, we cast the output areas to a list. This is because the map function returns a map object.<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t2\">2. filter<\/h3>\n<p>You can use the filter function to filter a list. This like filtering out the data you do not need. So you can select certain data from the list based on some criteria.<br \/>\nAssuming you have a list of scores. Now, you will like to filter out scores below average. Let&#8217;s write do this the normal way. Then we also do it using the filter function. Here we assume that for a list of scores, 50 is the average score.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">newscores <span style=\"color: #333333;\">=<\/span> []  <span style=\"color: #888888;\"># holds scores above average<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">for<\/span> score <span style=\"color: #000000; font-weight: bold;\">in<\/span> scores:\r\n    <span style=\"color: #008800; font-weight: bold;\">if<\/span> isaboveaverage(score):\r\n        \r\n        <span style=\"color: #888888;\"># if score is above average, add it to newscores<\/span>\r\n        newscores<span style=\"color: #333333;\">.<\/span>append(score)\r\n              \r\nscores <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: bold;\">45<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">70<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">94.2<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">75<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">51<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">49<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">35.1<\/span>]\r\n\r\n<span style=\"color: #007020;\">print<\/span>(newscores)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Again we can do this using the filter function. The code is given below:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">newscores <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">filter<\/span>(isaboveaverage, scores)\r\n<span style=\"color: #007020;\">print<\/span>(<span style=\"color: #007020;\">list<\/span>(newscores))\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Also, don&#8217;t forget that the output is converted back to list using the list function. This is because, the output of a filter function is a filter object. If you want to see what a filter object looks like, then first print it without converting.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Filtering out missing data<\/strong><\/p>\n<p>One area you can use the filter function is to filter out missing data in a dataset. For example, the list below contains names of students with some missing values.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">students <span style=\"color: #333333;\">=<\/span> [<span style=\"background-color: #fff0f0;\">\"Jadon\"<\/span>, <span style=\"background-color: #fff0f0;\">\"Solace\"<\/span>, <span style=\"background-color: #fff0f0;\">\"\"<\/span> <span style=\"background-color: #fff0f0;\">\"Treasure\"<\/span>, <span style=\"background-color: #fff0f0;\">\"\"<\/span>, <span style=\"background-color: #fff0f0;\">\"\"<\/span>, <span style=\"background-color: #fff0f0;\">\"Onyx\"<\/span>, <span style=\"background-color: #fff0f0;\">\"Booboo\"<\/span>]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>If you print this list, it would include the missing values. This is not desirable. To filter out this missing values, you can use the filter function. In this case, you pass in <em>None<\/em> as the first parameter.<\/p>\n<p>This is shown below:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">newStudents <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">filter<\/span>(<span style=\"color: #008800; font-weight: bold;\">None<\/span>, students)\r\n\r\n<span style=\"color: #007020;\">print<\/span>(<span style=\"color: #007020;\">list<\/span>(newStudents))\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>I recommend you try out all these yourself to see how it works. Maybe you can change up the dataset.<\/p>\n<p>&nbsp;<\/p>\n<h3 id=\"t3\">3. reduce<\/h3>\n<p>You use this this function to find some kind of aggregate of a list of item. The reduce function is a bit difference that the previous two. And you probably would not need to use if much. This is because, a loop tends to be better.<\/p>\n<p>&nbsp;<\/p>\n<p>Now this is how it works:<\/p>\n<p>It takes a sequence of items and applies a function to each item cumulatively. That means that it first applies the function to the first two items, then it applies the function to this result and the third item, then this result and the fourth item and so on. It continues until it reaches the last item.<\/p>\n<p>This is illustrated below<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-219 \" src=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce.jpg\" alt=\"Map, Filter and Reduce\" width=\"288\" height=\"251\" srcset=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce.jpg 562w, https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-300x262.jpg 300w\" sizes=\"auto, (max-width: 288px) 100vw, 288px\" \/><\/p>\n<p>Let&#8217;s take for example, finding the product of all numbers in a list. However, we need to first import the <em>reduce<\/em> function from the <em>functools<\/em> module.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">from<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">functools<\/span> <span style=\"color: #008800; font-weight: bold;\">import<\/span> reduce\r\n\r\ndata <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">5<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">3<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">1.2<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">2.6<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">3.5<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">1<\/span>]\r\n\r\nproduct <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">lambda<\/span> x, y: x<span style=\"color: #333333;\">*<\/span>y\r\n\r\nresult <span style=\"color: #333333;\">=<\/span> reduce(product, data)\r\n<\/pre>\n<p><strong>Watch the Video<\/strong><br \/>\n<iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/apQ_-Og2Gh0\" width=\"100%\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\ufeff<\/span><\/iframe><\/p>\n<p>Remember, you will understand it better if you do it yourself. Do leave a comment if you have any.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can perform some kind of data analytics on sets of data in Python. This is made possible by certain functions and constructs. In this &hellip; <\/p>\n","protected":false},"author":395,"featured_media":220,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-218","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python - Map, Filter, Reduce - Python Tutorials<\/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:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python - Map, Filter, Reduce - Python Tutorials\" \/>\n<meta property=\"og:description\" content=\"You can perform some kind of data analytics on sets of data in Python. This is made possible by certain functions and constructs. In this &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-17T23:37:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-02T03:57:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1005\" \/>\n\t<meta property=\"og:image:height\" content=\"544\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Python &#8211; Map, Filter, Reduce\",\"datePublished\":\"2019-02-17T23:37:33+00:00\",\"dateModified\":\"2019-03-02T03:57:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/\"},\"wordCount\":642,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Map-Filter-and-Reduce-in-Python.jpg\",\"articleSection\":[\"Python Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/\",\"name\":\"Python - Map, Filter, Reduce - Python Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Map-Filter-and-Reduce-in-Python.jpg\",\"datePublished\":\"2019-02-17T23:37:33+00:00\",\"dateModified\":\"2019-03-02T03:57:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Map-Filter-and-Reduce-in-Python.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/wp-content\\\/uploads\\\/sites\\\/8\\\/2019\\\/02\\\/Map-Filter-and-Reduce-in-Python.jpg\",\"width\":1005,\"height\":544,\"caption\":\"Map, Filter and Reduce in Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/21-python-map-filter-reduce\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python &#8211; Map, Filter, Reduce\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/\",\"name\":\"Python Tutorials\",\"description\":\"Python Tutorial for Programming and Data Science\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/python\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python - Map, Filter, Reduce - Python Tutorials","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:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/","og_locale":"en_US","og_type":"article","og_title":"Python - Map, Filter, Reduce - Python Tutorials","og_description":"You can perform some kind of data analytics on sets of data in Python. This is made possible by certain functions and constructs. In this &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/","og_site_name":"Python Tutorials","article_published_time":"2019-02-17T23:37:33+00:00","article_modified_time":"2019-03-02T03:57:00+00:00","og_image":[{"width":1005,"height":544,"url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Python &#8211; Map, Filter, Reduce","datePublished":"2019-02-17T23:37:33+00:00","dateModified":"2019-03-02T03:57:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/"},"wordCount":642,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg","articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/","url":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/","name":"Python - Map, Filter, Reduce - Python Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg","datePublished":"2019-02-17T23:37:33+00:00","dateModified":"2019-03-02T03:57:00+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/python\/wp-content\/uploads\/sites\/8\/2019\/02\/Map-Filter-and-Reduce-in-Python.jpg","width":1005,"height":544,"caption":"Map, Filter and Reduce in Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/python\/21-python-map-filter-reduce\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/python\/"},{"@type":"ListItem","position":2,"name":"Python &#8211; Map, Filter, Reduce"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/python\/#website","url":"https:\/\/www.kindsonthegenius.com\/python\/","name":"Python Tutorials","description":"Python Tutorial for Programming and Data Science","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/python\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/python\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/python\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/comments?post=218"}],"version-history":[{"count":5,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/218\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/posts\/218\/revisions\/225"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media\/220"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/media?parent=218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/categories?post=218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/python\/wp-json\/wp\/v2\/tags?post=218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}