{"id":69,"date":"2023-06-08T00:15:12","date_gmt":"2023-06-08T00:15:12","guid":{"rendered":"https:\/\/feellikelearning.com\/en\/?p=69"},"modified":"2023-06-08T00:15:12","modified_gmt":"2023-06-08T00:15:12","slug":"what-is-funcy-collecting-in-python","status":"publish","type":"post","link":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/","title":{"rendered":"What is funcy.collecting in python?"},"content":{"rendered":"\n<p>In Python, <code>funcy.collecting<\/code> refers to a module provided by the Funcy library. Funcy is a functional programming library for Python that aims to enhance and simplify common programming tasks.<\/p>\n\n\n\n<p>The <code>funcy.collecting<\/code> module provides functions for working with collections, such as lists, dictionaries, and other iterable objects. It offers various utilities to collect, transform, and manipulate data in a functional programming style.<\/p>\n\n\n\n<p>Here are a few examples of functions available in <code>funcy.collecting<\/code>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>concat<\/code>: Concatenates multiple iterables into a single iterable.<\/li>\n\n\n\n<li><code>dedupe<\/code>: Removes duplicate elements from an iterable while preserving the order.<\/li>\n\n\n\n<li><code>pluck<\/code>: Extracts a specific attribute or key from a sequence of objects or dictionaries.<\/li>\n\n\n\n<li><code>project<\/code>: Selects specific keys from a dictionary, creating a new dictionary with the selected keys and their corresponding values.<\/li>\n\n\n\n<li><code>group_by<\/code>: Groups elements from an iterable based on a key function.<\/li>\n\n\n\n<li><code>imap<\/code>: Maps a function over an iterable or a sequence of iterables, returning an iterator.<\/li>\n<\/ul>\n\n\n\n<p>These functions, along with others provided by the <code>funcy.collecting<\/code> module, can be used to write concise and expressive code for data manipulation and transformation tasks in Python.<\/p>\n\n\n\n<p>To use <code>funcy.collecting<\/code> in your Python code, you need to install the <code>funcy<\/code> library first. You can install it using <code>pip<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install funcy\n<\/code><\/pre>\n\n\n\n<p>Once installed, you can import the <code>funcy.collecting<\/code> module and use its functions in your code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from funcy.collecting import concat, dedupe, pluck\n\n# Example usage\ndata = &#91;1, 2, 2, 3, 4, 4, 5]\nresult = list(dedupe(data))\nprint(result)  # &#91;1, 2, 3, 4, 5]\n\n# Another example\nitems = &#91;{'name': 'John', 'age': 25}, {'name': 'Alice', 'age': 30}]\nnames = list(pluck('name', items))\nprint(names)  # &#91;'John', 'Alice']\n<\/code><\/pre>\n\n\n\n<p>These examples demonstrate the usage of <code>dedupe<\/code> to remove duplicates from a list and <code>pluck<\/code> to extract a specific key from a list of dictionaries. Funcy provides many more functions that can be explored in the official documentation: <a href=\"https:\/\/github.com\/Suor\/funcy\">https:\/\/github.com\/Suor\/funcy<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Python, funcy.collecting refers to a module provided by the Funcy library. Funcy is a functional programming library for Python that aims to enhance and simplify common programming tasks. The funcy.collecting module provides functions for working with collections, such as lists, dictionaries, and other iterable objects. It offers various utilities to collect, transform, and manipulate [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is funcy.collecting in python? - Feel Like Learning<\/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:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is funcy.collecting in python? - Feel Like Learning\" \/>\n<meta property=\"og:description\" content=\"In Python, funcy.collecting refers to a module provided by the Funcy library. Funcy is a functional programming library for Python that aims to enhance and simplify common programming tasks. The funcy.collecting module provides functions for working with collections, such as lists, dictionaries, and other iterable objects. It offers various utilities to collect, transform, and manipulate [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Feel Like Learning\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-08T00:15:12+00:00\" \/>\n<meta name=\"author\" content=\"feellikelearning\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"feellikelearning\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/\",\"url\":\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/\",\"name\":\"What is funcy.collecting in python? - Feel Like Learning\",\"isPartOf\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/#website\"},\"datePublished\":\"2023-06-08T00:15:12+00:00\",\"dateModified\":\"2023-06-08T00:15:12+00:00\",\"author\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7\"},\"breadcrumb\":{\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/feellikelearning.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What is funcy.collecting in python?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#website\",\"url\":\"https:\/\/feellikelearning.com\/en\/\",\"name\":\"Feel Like Learning\",\"description\":\"keep curiosity alive\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/feellikelearning.com\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7\",\"name\":\"feellikelearning\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g\",\"caption\":\"feellikelearning\"},\"sameAs\":[\"http:\/\/feellikelearning.com\/en\"],\"url\":\"https:\/\/feellikelearning.com\/en\/index.php\/author\/feellikelearning\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is funcy.collecting in python? - Feel Like Learning","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:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/","og_locale":"en_US","og_type":"article","og_title":"What is funcy.collecting in python? - Feel Like Learning","og_description":"In Python, funcy.collecting refers to a module provided by the Funcy library. Funcy is a functional programming library for Python that aims to enhance and simplify common programming tasks. The funcy.collecting module provides functions for working with collections, such as lists, dictionaries, and other iterable objects. It offers various utilities to collect, transform, and manipulate [&hellip;]","og_url":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/","og_site_name":"Feel Like Learning","article_published_time":"2023-06-08T00:15:12+00:00","author":"feellikelearning","twitter_card":"summary_large_image","twitter_misc":{"Written by":"feellikelearning","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/","url":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/","name":"What is funcy.collecting in python? - Feel Like Learning","isPartOf":{"@id":"https:\/\/feellikelearning.com\/en\/#website"},"datePublished":"2023-06-08T00:15:12+00:00","dateModified":"2023-06-08T00:15:12+00:00","author":{"@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7"},"breadcrumb":{"@id":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/feellikelearning.com\/en\/index.php\/2023\/06\/08\/what-is-funcy-collecting-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/feellikelearning.com\/en\/"},{"@type":"ListItem","position":2,"name":"What is funcy.collecting in python?"}]},{"@type":"WebSite","@id":"https:\/\/feellikelearning.com\/en\/#website","url":"https:\/\/feellikelearning.com\/en\/","name":"Feel Like Learning","description":"keep curiosity alive","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/feellikelearning.com\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/1ec5aac313d6de20215fe2b8e176b8a7","name":"feellikelearning","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/feellikelearning.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/36aec9d519f02362e3e89b0716ae640d08701f57e818830f3f197db5fbc1ae20?s=96&d=mm&r=g","caption":"feellikelearning"},"sameAs":["http:\/\/feellikelearning.com\/en"],"url":"https:\/\/feellikelearning.com\/en\/index.php\/author\/feellikelearning\/"}]}},"_links":{"self":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":1,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":70,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions\/70"}],"wp:attachment":[{"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/feellikelearning.com\/en\/index.php\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}