<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AW — notes &amp; thoughts</title><link>https://coffepowered.github.io/</link><description>Recent content on AW — notes &amp; thoughts</description><generator>Hugo -- gohugo.io</generator><language>it-IT</language><managingEditor>Andrea Ruggerini</managingEditor><webMaster>Andrea Ruggerini</webMaster><lastBuildDate>Sat, 10 May 2025 21:28:43 -0500</lastBuildDate><atom:link href="https://coffepowered.github.io/index.xml" rel="self" type="application/rss+xml"/><item><title>Drawing a coffee plot, with LLMs ep0</title><link>https://coffepowered.github.io/blogs/coffe/</link><pubDate>Sat, 10 May 2025 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/coffe/</guid><description>&lt;h1 id="llm-assisted-work"&gt;LLM-assisted work?&lt;/h1&gt;
&lt;p&gt;Will the LLM take over us? Yes, no. Maybe.&lt;/p&gt;
&lt;p&gt;The only thing I&amp;rsquo;m sure about is that those cool stuff are not able to assess the certainty of text (&amp;ldquo;opinions?&amp;rdquo;) they generate.&lt;/p&gt;
&lt;p&gt;Moreover, In my humanly-limited experience, I have yet to see LLMs to meaningful contribute to any asset, i.e. to add valuable and extensive contribution to non-throaway code. All of this may seem strong, but hey, this does not mean productivity cannot be positively impacted.&lt;/p&gt;</description></item><item><title>Sparse notes</title><link>https://coffepowered.github.io/blogs/2022-sparse-notes/</link><pubDate>Wed, 01 Mar 2023 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/2022-sparse-notes/</guid><description>&lt;h2 id="data-science"&gt;Data science&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; &lt;a href="https://bookdown.org/max/FES/"&gt;Effect of irrelevant features&lt;/a&gt; - a nice experimental test&lt;/li&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; &lt;a href="https://www.coursera.org/learn/competitive-data-science/lecture/8o1Hc/matrix-factorizations"&gt;Matrix factorizaton recap in 6minutes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; &lt;a href="https://www.kaggle.com/code/vprokopev/mean-likelihood-encodings-a-comprehensive-study/notebook"&gt;mean encodings: a comprehesive study&lt;/a&gt;, check also &lt;a href="https://github.com/scikit-learn-contrib/category_encoders"&gt;category_encoders sklearn library&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; relationship between &lt;a href="https://stats.stackexchange.com/questions/134282/relationship-between-svd-and-pca-how-to-use-svd-to-perform-pca"&gt;SVD and PCA&lt;/a&gt; + a comprehensive &lt;a href="https://arxiv.org/pdf/1404.1100.pdf"&gt;tutorial on arxiv&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; Naive-Bayes classification from &lt;a href="https://jakevdp.github.io/PythonDataScienceHandbook/05.05-naive-bayes.html"&gt;scratch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://arxiv.org/abs/2203.05556"&gt;On Embeddings for Numerical Features in Tabular Deep Learning&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cmry.github.io/notes/euclidean-v-cosine"&gt;Euclidean vs cosine distance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="data-viz"&gt;Data viz&lt;/h2&gt;
&lt;h2 id="complimentary"&gt;Complimentary&lt;/h2&gt;
&lt;h2 id="temporary"&gt;Temporary&lt;/h2&gt;
&lt;p&gt;Staging area for links that will be forgotten soon:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; &lt;a href="https://www.kaggle.com/competitions/h-and-m-personalized-fashion-recommendations/data"&gt;H&amp;amp;M personalized fashion&lt;/a&gt; reccomendation&lt;/li&gt;
&lt;li&gt;&lt;code&gt;march&lt;/code&gt; learning &lt;a href="https://wattenberger.com/blog/d3"&gt;D3js&lt;/a&gt; + &lt;a href="https://www.linkedin.com/learning/d3-js-essential-training-for-data-scientists/what-you-need-to-know"&gt;essential training&lt;/a&gt; + custom visuals into &lt;a href="https://www.linkedin.com/learning/advanced-power-bi-custom-visuals-with-d3-js/intro-to-microsoft-power-bi?u=2057564"&gt;powerbi&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Q1 2023: Miscellanea (playlist)</title><link>https://coffepowered.github.io/blogs/q1-2023-podcasts-and-readings/</link><pubDate>Wed, 01 Feb 2023 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/q1-2023-podcasts-and-readings/</guid><description>&lt;h1 id="usare-i-numeri-ciecamente-la-fallacia-di-mcnamara"&gt;Usare i numeri ciecamente: la fallacia di McNamara&lt;/h1&gt;
&lt;p&gt;Due note brevi sulla &lt;a href="https://en.wikipedia.org/wiki/McNamara_fallacy"&gt;fallacia di McNamara&lt;/a&gt; (segretario della difesa USA durante la guerra in Vietnam), spesso riassunta come &amp;ldquo;fallacia quantitativa&amp;rdquo;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“the facts which count best count most&amp;quot;. [I fatti che si contano meglio sono quelli che contano di più]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Spesso è figlia delle organizzazioni, ma colpisce (duro) individui e decisioni. Come fare a riprodurla? Ecco un tutorial (preso da &lt;a href="https://www.researchgate.net/publication/346625931_The_McNamara_fallacy_and_the_fog_of_foresight_at_work_This_article_first_appeared_in_Health_and_Safety_Bulletin_published_by_LexisNexis_Further_details_from_the_editor_Howard_Fidderman_hfiddermanexcit"&gt;qui&lt;/a&gt;):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;As reported by Smith, Yankelovich describes the fallacy as follows:&lt;/p&gt;</description></item><item><title>What's all that for? Thinking of the BTC energy consumptions</title><link>https://coffepowered.github.io/blogs/on-the-btc-energy-toll/</link><pubDate>Tue, 10 Jan 2023 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/on-the-btc-energy-toll/</guid><description>&lt;h2 id="i-can-remember-the-snow"&gt;I can remember the snow&lt;/h2&gt;
&lt;p&gt;Born on the cusp of the 90s, I was privileged to witness a period of great optimism and progress. The winds of freedom and democracy seemed to be blowing strong, and economies were thriving. One particularly noteworthy achievement from this time was the establishment of the &lt;a href="https://www.unep.org/ozonaction/who-we-are/about-montreal-protocol"&gt;Montreal Protocol&lt;/a&gt;, a treaty designed to phase out ozone-depleting substances, a move that has proven highly successful.&lt;/p&gt;
&lt;p&gt;I have fond memories of being a child during this time, including TV commercials&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt; that highlighted the importance of protecting polar bears. Even after all these years, the imagery of these ads stays with me, and their message continues to resonate, a testament to their powerful impact.&lt;/p&gt;</description></item><item><title>A (reasonably) complex radar chart</title><link>https://coffepowered.github.io/blogs/complex-radar-python/</link><pubDate>Fri, 11 Mar 2022 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/complex-radar-python/</guid><description>&lt;p&gt;A radar (or spider) chart is a convenient method of displaying multivariate data in a form of 2-dimensional chart.&lt;/p&gt;
&lt;p&gt;When I say convenient, I mean it is particularly well-accepted by people and gives a good intuition when comparing different items/subjects.&lt;/p&gt;
&lt;p&gt;Think about comparing 2 (or more) football players in terms of dribbling, running speed, shots and pressure. Even with only four variables bar plot would become cumbersome to deal with and not immediate to perceive. That&amp;rsquo;s why they are particularly &lt;a href="https://statsbomb.com/articles/soccer/revisiting-radars/"&gt;popular in sports analytics&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>The economics of the agri-food value chain</title><link>https://coffepowered.github.io/blogs/economics-agri-food-value-chain/</link><pubDate>Tue, 01 Mar 2022 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/economics-agri-food-value-chain/</guid><description>&lt;h1 id="course-review"&gt;Course review&lt;/h1&gt;
&lt;p&gt;Let me paraphrase what Tukey once said: I truly believe that getting in contact with different fields and expertise is one of the perks of being a data scientist. Pictorially:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The best thing about being a &lt;del&gt;statistician&lt;/del&gt; data scientist, Mr Tukey once told a colleague, is that you get to play in everyone&amp;rsquo;s backyard.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;So, even if you can legitimately play in everyone&amp;rsquo;s backyard - which oftentimes means cleaning it as a first step, it also means that you will be speaking to people with different backgrounds ad expertise.&lt;/p&gt;</description></item><item><title>Google 20 for 1 stock split</title><link>https://coffepowered.github.io/blogs/google-stock-split/</link><pubDate>Wed, 02 Feb 2022 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/google-stock-split/</guid><description>&lt;p&gt;Google announced Tuesday its results for Q4 2021 &lt;em&gt;and&lt;/em&gt; that they plan to split shares at 20 for 1 this Tuesday. Basically, if you are a shareholder, for each 1 share of Google at (about) 3000$ dollars you will have (at the ex-date) 20 shares at 150$.&lt;/p&gt;
&lt;p&gt;Nothing should really change, but there might be some financial effects, for instance, due to the &lt;a href="https://www.barrons.com/articles/alphabet-stock-split-51643842562"&gt;inclusion of the stock in new indices&lt;/a&gt; or increased market liquidity.&lt;/p&gt;</description></item><item><title>Crescita Economica</title><link>https://coffepowered.github.io/blogs/crescita-economica/</link><pubDate>Sun, 31 Jan 2021 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/crescita-economica/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Questa pagina traduce liberamente e parzialmente, l&amp;rsquo;articolo di Max Roser (&lt;a href="https://creativecommons.org/licenses/by/4.0/"&gt;secondo licenza&lt;/a&gt;) (2013) - &amp;ldquo;Economic Growth&amp;rdquo;. &lt;a href="https://ourworldindata.org/economic-growth"&gt;Published online at OurWorldInData&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Riferitevi alla versione originale per le citazioni e per il testo completo, io mi sono permesso di aggiungere qualche nota interessante per noi italiani.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Con &lt;strong&gt;crescita economica&lt;/strong&gt; descriviamo un aumento nella qualità a quantità dei beni e servizi economici che una società produce o consuma.&lt;/p&gt;
&lt;p&gt;Mentre la definizione di crescita economica è chiara, misurare la crescita in sè risulta estremamente difficile. La crescita è spesso misurata tramite un aumento nel reddito delle famiglie o del PIL (aggiustato per l&amp;rsquo;inflazione), ma è importante ricordare che queste misure non sono la definizione di crescita - proprio come l&amp;rsquo;aspettativa di vita è una misura della &amp;ldquo;salute di una popolazione&amp;rdquo; ma certamente non coincide con la definizione stessa. Le misure legate al reddito sono solamente un modo di capire la diseguaglianza tra paesi e la variazione di ricchezza nel tempo.&lt;/p&gt;</description></item><item><title>Short notes on namedtuples, NamedTuples and Data classes</title><link>https://coffepowered.github.io/blogs/python-data-typer-for-data/</link><pubDate>Mon, 11 Jan 2021 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/python-data-typer-for-data/</guid><description>&lt;p&gt;Both dataclasses and tuples are based on the &lt;a href="https://www.attrs.org/en/stable/"&gt;attrs&lt;/a&gt; project, the one Python Library &lt;a href="https://glyph.twistedmatrix.com/2016/08/attrs.html"&gt;everybody needs&lt;/a&gt; and are fast object types (&lt;a href="https://refactoring.guru/design-patterns/factory-method"&gt;factory methods&lt;/a&gt;) designed to simplify and reduce code.&lt;/p&gt;
&lt;h2 id="namedtuple-and-namedtuple"&gt;namedtuple and NamedTuple&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Both &lt;code&gt;immutable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Tuple-based (hence fast) but far &lt;a href="https://www.attrs.org/en/stable/why.html"&gt;better&lt;/a&gt; than tuples&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;NamedTuple&lt;/strong&gt; is the typed version of &lt;strong&gt;namedtuple&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;immutable, iterable, hashable, unpackable&lt;/li&gt;
&lt;li&gt;backward-compatible with &lt;strong&gt;tuple&lt;/strong&gt; (e.g you can access a namedtuple by index)&lt;/li&gt;
&lt;li&gt;default arguments supported from Python 3.7+&lt;/li&gt;
&lt;li&gt;fast! C-based&lt;/li&gt;
&lt;li&gt;example &lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Point &lt;span style="color:#f92672"&gt;=&lt;/span&gt; namedtuple(&lt;span style="color:#e6db74"&gt;&amp;#39;Point&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;x y&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pt1 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Point(&lt;span style="color:#ae81ff"&gt;1.0&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;5.0&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pt2 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Point(&lt;span style="color:#ae81ff"&gt;2.5&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;1.5&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; math &lt;span style="color:#f92672"&gt;import&lt;/span&gt; sqrt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# use index referencing&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;line_length &lt;span style="color:#f92672"&gt;=&lt;/span&gt; sqrt((pt1[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;]&lt;span style="color:#f92672"&gt;-&lt;/span&gt;pt2[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;])&lt;span style="color:#f92672"&gt;**&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; (pt1[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]&lt;span style="color:#f92672"&gt;-&lt;/span&gt;pt2[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;])&lt;span style="color:#f92672"&gt;**&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# use tuple unpacking&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;x1, y1 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pt1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="dataclasses"&gt;Dataclasses&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Are &lt;code&gt;mutable&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.python.org/3/library/dataclasses.html"&gt;post-init processing&lt;/a&gt; can be used to create fields depending on other fields or even to perform input validation&lt;sup id="fnref:2"&gt;&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref"&gt;2&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;li&gt;all implementation is written in Python, so &lt;a href="https://stackoverflow.com/questions/51671699/data-classes-vs-typing-namedtuple-primary-use-cases"&gt;slower&lt;/a&gt; wrt tuple-based data types&lt;/li&gt;
&lt;li&gt;Validation of types at runtime not supported natively (or &lt;a href="https://stackoverflow.com/questions/50563546/validating-detailed-types-in-python-dataclasses"&gt;cumbersome&lt;/a&gt;) but easy with decorator &lt;a href="https://pypi.org/project/enforce-typing/"&gt;@enforce_typing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;from Python 3.7&lt;/li&gt;
&lt;li&gt;are just regular Classes (e.g. inheritance) withot writing boilerplate code&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.python.org/dev/peps/pep-0557/#why-not-just-use-namedtuple"&gt;inappropriate&lt;/a&gt; when API compatibility with tuples or dicts is requested&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=T-TwcmT6Rcw&amp;amp;t=1390"&gt;bonus&lt;/a&gt; PyCon talk, if you have time&lt;/li&gt;
&lt;li&gt;example&lt;sup id="fnref:3"&gt;&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref"&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; dataclasses &lt;span style="color:#f92672"&gt;import&lt;/span&gt; dataclass
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;@dataclass&lt;/span&gt;(unsafe_hash&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;True&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;InventoryItem&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&amp;#39;Class for keeping track of an item in inventory.&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; name: str
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; unit_price: float
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; quantity_on_hand: int &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;total_cost&lt;/span&gt;(self) &lt;span style="color:#f92672"&gt;-&amp;gt;&lt;/span&gt; float:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;unit_price &lt;span style="color:#f92672"&gt;*&lt;/span&gt; self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;quantity_on_hand
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="other-fancy-data-types-not-from-the-stdlib"&gt;Other fancy data types (not from the stdlib)&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pydantic-docs.helpmanual.io/"&gt;pydantic&lt;/a&gt;: enforces type hints at runtime providing user-readable errors when data is invalid. Seems relatively popular.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# sample input val via Regexp&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; dataclasses &lt;span style="color:#f92672"&gt;import&lt;/span&gt; dataclass
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; re
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;@dataclass&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;class&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Widget&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; id: int
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;__post_init__&lt;/span&gt;(self):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; id_condition &lt;span style="color:#f92672"&gt;=&lt;/span&gt; re&lt;span style="color:#f92672"&gt;.&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;match&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;r&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;[0-9]&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{4}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;, str(self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;id))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;not&lt;/span&gt; id_condition:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;f&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;{&lt;/span&gt;self&lt;span style="color:#f92672"&gt;.&lt;/span&gt;id&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt; doesn&amp;#39;t follow pattern [0-9]&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;&amp;#123;&amp;#123;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;4&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;&amp;#125;&amp;#125;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;raise&lt;/span&gt; CustomException
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="footnotes" role="doc-endnotes"&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;&lt;a href="https://stackoverflow.com/questions/2970608/what-are-named-tuples-in-python"&gt;brief&lt;/a&gt; explanation on stackoverlow&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink"&gt;&amp;#x21a9;&amp;#xfe0e;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Add a row to pandas' DataFrame</title><link>https://coffepowered.github.io/blogs/pandas-append-rows-to-df/</link><pubDate>Sat, 31 Oct 2020 21:28:43 -0500</pubDate><guid>https://coffepowered.github.io/blogs/pandas-append-rows-to-df/</guid><description>&lt;p&gt;Quite often, it is needed to &lt;em&gt;fill&lt;/em&gt; or modify dataframes with data that gets computed at runtime. This post draws heavily from the stackoverlow question &amp;ldquo;&lt;a href="https://stackoverflow.com/questions/10715965/add-one-row-to-pandas-dataframe/24913075#24913075"&gt;Add one row to pandas DataFrame&lt;/a&gt;&amp;rdquo;. Here I show the 4 methods that were proposed to append the data and discuss them. A 5th &amp;ldquo;improper&amp;rdquo; method operating on columns is added just for sake of comparison with respect to the most efficient option.&lt;/p&gt;
&lt;p&gt;If you want just the takeaways:&lt;/p&gt;</description></item></channel></rss>