class="sd">  df</span>
<span class="sd">    a messy pandas data frame.</span>

<span class="sd">  &quot;&quot;&quot;</span>
  <span class="c1"># Put one &#39;nan&#39; in 25% of the rows, then one inf in 25%.</span>
  <span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">as_matrix</span><span class="p">()</span>
  <span class="kn">from</span> <span class="nn">sklearn</span> <span class="k">import</span> <span class="n">datasets</span>
  <span clas