speed up pandas calculation

Skip Montanaro skip.montanaro at gmail.com
Wed Jul 30 22:28:59 EDT 2014


On Wed, Jul 30, 2014 at 8:11 PM, Chris Kaynor <ckaynor at zindagigames.com> wrote:
> Another way to write this, using a list expression (untested):
> new_df = [col for col in df if col.value in keep_col]

As I am learning (often painfully) with pandas and JavaScript+(d3 or
jQuery), loops are the enemy. You want to operate on large chunks of
data simultaneously. In pandas, those chunks are thinly disguised
numpy arrays. In JS+(ds or jQuery), those chunks are selections from
the DOM.

I should have paid closer attention to the APL unit of my programming
languages survey class in college.

Skip



More information about the Python-list mailing list