<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Are lambda functions considered bad practice? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105472#M42145</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/139254"&gt;@ls&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Using multiple lambda functions in your code is not necessarily bad, you should consider the readability, maintainability, and reusability of your code. If the lambda functions are simple and the logic is clear, then it's fine to use them. Otherwise, consider defining named functions to improve the overall quality of your code&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2025 19:16:04 GMT</pubDate>
    <dc:creator>Alberto_Umana</dc:creator>
    <dc:date>2025-01-13T19:16:04Z</dc:date>
    <item>
      <title>Are lambda functions considered bad practice?</title>
      <link>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105470#M42143</link>
      <description>&lt;P&gt;As the title suggests I have a bunch of lambda functions within my notebooks and I wanted to know if it is considered to be "bad" to have them in there.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;output_list &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; json_files.&lt;/SPAN&gt;&lt;SPAN&gt;mapPartitions&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;lambda&lt;/SPAN&gt; &lt;SPAN&gt;partition&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;iter&lt;/SPAN&gt;&lt;SPAN&gt;([&lt;/SPAN&gt;&lt;SPAN&gt;process_partition&lt;/SPAN&gt;&lt;SPAN&gt;(partition)])) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;.filter&lt;/SPAN&gt;&lt;SPAN&gt;(lambda df: not df.empty) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;flatMap&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;lambda&lt;/SPAN&gt; &lt;SPAN&gt;df&lt;/SPAN&gt;&lt;SPAN&gt;: df.&lt;/SPAN&gt;&lt;SPAN&gt;to_dict&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;orient&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"records"&lt;/SPAN&gt;&lt;SPAN&gt;)) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;map&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;lambda&lt;/SPAN&gt; &lt;SPAN&gt;row_dict&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;Row&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;**&lt;/SPAN&gt;&lt;SPAN&gt;row_dict)) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;toDF&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The code above works but I wanted to know if it is ok to have that many lambda functions together.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Jan 2025 19:08:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105470#M42143</guid>
      <dc:creator>ls</dc:creator>
      <dc:date>2025-01-13T19:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Are lambda functions considered bad practice?</title>
      <link>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105472#M42145</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/139254"&gt;@ls&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Using multiple lambda functions in your code is not necessarily bad, you should consider the readability, maintainability, and reusability of your code. If the lambda functions are simple and the logic is clear, then it's fine to use them. Otherwise, consider defining named functions to improve the overall quality of your code&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 19:16:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105472#M42145</guid>
      <dc:creator>Alberto_Umana</dc:creator>
      <dc:date>2025-01-13T19:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Are lambda functions considered bad practice?</title>
      <link>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105474#M42146</link>
      <description>&lt;P class="_1t7bu9h1 paragraph"&gt;Using lambda functions within notebooks is not inherently "bad," but there are some considerations to keep in mind.&amp;nbsp;While this code is functional, chaining multiple lambda functions can reduce readability and debugging capabilities in Databricks notebooks.&amp;nbsp;Error tracebacks become less informative.&amp;nbsp;&lt;/P&gt;
&lt;P class="_1t7bu9h1 paragraph"&gt;If there is any performance implications, it is difficult to add logging and&amp;nbsp;inspect intermediate results&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 19:28:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/are-lambda-functions-considered-bad-practice/m-p/105474#M42146</guid>
      <dc:creator>Satyadeepak</dc:creator>
      <dc:date>2025-01-13T19:28:46Z</dc:date>
    </item>
  </channel>
</rss>

