What’s the alternative to pandas chain indexing?

Use multi-axis indexing, e.g. df.loc[‘a’, ‘1’] When you use df[‘1’][‘a’], you are first accessing the series object s = df[‘1’], and then accessing the series element s[‘a’], resulting in two __getitem__ calls, both of which are heavily overloaded (handle a lot of scenarios, like slicing, boolean mask indexing, and so on). It’s much more efficient … Read more

How to make chainable function in JavaScript?

Sure, the trick is to return the object once you’re done modifying it: String.prototype.foo = function() { return this + “+”; } var str = “Notepad”; console.log(str.foo().foo().toUpperCase()); http://jsfiddle.net/Xeon06/vyFek/ To make the method available on String, I’m modifying it’s prototype. Be careful not to do this on Object though, as it can cause problems when enumerating … Read more