<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Pandas on Noetic Nought</title>
    <link>https://punchagan.muse-amuse.in/tags/pandas/</link>
    <description>Recent content in Pandas on Noetic Nought</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <copyright>© 2006-2026 CC-BY-SA-4.0</copyright>
    <lastBuildDate>Tue, 24 Jun 2014 09:44:34 -0400</lastBuildDate>
    <atom:link href="https://punchagan.muse-amuse.in/tags/pandas/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Recurse Center, 2014-06-24</title>
      <link>https://punchagan.muse-amuse.in/recurse-center/recurse-center-2014-06-24/</link>
      <pubDate>Tue, 24 Jun 2014 09:44:34 -0400</pubDate>
      <guid>https://punchagan.muse-amuse.in/recurse-center/recurse-center-2014-06-24/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I worked for the whole day on implementing &lt;a href=&#34;http://www.tandfonline.com/doi/abs/10.1080/0161-119591883944&#34;&gt;an algorithm&lt;/a&gt; to analyze a&#xA;cipher text, and guess the substitution cipher used.  The algorithm&#xA;was pretty straight forward, and I had it &amp;ldquo;mostly&amp;rdquo; working, in a&#xA;couple of hours.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;I then began to refactor it, and found that there was what looked&#xA;like a bug, and I &amp;ldquo;fixed&amp;rdquo; it mindlessly.  I was essentially trying&#xA;to swap 2 rows, and columns of a pandas data frame.  I had a&#xA;data-frame &lt;code&gt;D&lt;/code&gt; and its copy &lt;code&gt;D_&lt;/code&gt;.  I was trying to swap 2 rows and&#xA;columns of &lt;code&gt;D_&lt;/code&gt;.  I found that the code was initially using the data&#xA;from &lt;code&gt;D&lt;/code&gt; to do the swap.  To fix it, I checked if tuple unpacking&#xA;did the right thing.  It looked like it did.  So, I used something&#xA;like &lt;code&gt;_D[&#39;a&#39;], D_[&#39;b&#39;] = D_[&#39;b&#39;], D_[&#39;a&#39;]&lt;/code&gt;.  Essentially, changed &lt;code&gt;D&lt;/code&gt;&#xA;on the right hand side to &lt;code&gt;D_&lt;/code&gt;.  I thought I had tested this on the&#xA;terminal, but after hours of debugging (along with fixing another&#xA;minor issue), I later found out that the tuple unpacking doesn&amp;rsquo;t&#xA;work and the swapped rows and columns actually become equal!  I had&#xA;suspected this initially, and had &amp;ldquo;tested&amp;rdquo; this manually, I&#xA;thought.  These are the kinds of things that should have tests for,&#xA;I think.  It wouldn&amp;rsquo;t have taken me too long to write a test, and I&#xA;could have been totally sure that it works!  (I was manually reading&#xA;off values in the array, and probably messed up somewhere)&lt;/p&gt;&#xA;&lt;p&gt;FWIW, the code now reads &lt;kbd&gt;&lt;em&gt;D[&amp;lsquo;a&amp;rsquo;], D&lt;/em&gt;[&amp;lsquo;b&amp;rsquo;] = D_[&amp;lsquo;b&amp;rsquo;].copy(),&#xA;D_[&amp;lsquo;a&amp;rsquo;].copy()&lt;/kbd&gt;&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;The algo seems to need about 1000 characters to get past the 90%&#xA;accuracy mark.  I could probably tweak it a little to perform&#xA;better, but I&amp;rsquo;m going to leave it here, for now, and move on to the&#xA;signal processing parts.  I&amp;rsquo;m not totally sure how the signal&#xA;processing would work, and whether we could actually map back the&#xA;keystrokes to a substitution cipher enciphered text.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;If required, the tweaks could be -&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Use trigrams instead of bigrams&lt;/li&gt;&#xA;&lt;li&gt;Add a degree of dictionary look-ups: May be something like,&#xA;look-up all the deciphered words, and try not swapping the&#xA;characters that appear in most of the words that are in the&#xA;dictionary.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;This paper is 20 years old, and there would surely be work by others&#xA;building on top of this, or doing it totally differently.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
  </channel>
</rss>
