An Introduction to Scientific Python – Pandas
As an R user I noticed a couple of oddities.  First,<p><pre><code>  len(df)
</code></pre>
returns the number of rows rather than the number of columns.  This strikes me as a bad idea, because data-frames are better thought of as a collection of columns.   Typically you want to loop over the columns of a data-frame and not so much over its rows, which is performance-wise much more costly.<p>Second, the apply method seems totally redundant.  Why call a method that calls a function when you can simply call the function directly<p><pre><code>  df[&#x27;year&#x27;] = base_year(df.water_year)
</code></pre>
Probably I&#x27;m missing something here.