3 ms·
Here are two options which various people might find intuitive: 1. Make a good old numeric for loop like "for ii in range(len(df))" with df.iloc or df.ix, etc.
by jzwinck 6y ago
Here are two options which various people might find intuitive:
1. Make a good old numeric for loop like "for ii in range(len(df))" with df.iloc or df.ix, etc.
2. Use df.apply() to create a new DataFrame with your changes.
Both of these are mentioned in brief answers to that SO post. But not in the accepted answer. A lot of the answers focus on the most efficient ways to do things, even though the question was very basic and did not imply the data were large.
- smabie 6y agoIt's not even about performance, writing vectorized code is just superior. The array language model is very powerful and you can literally write a couple lines of code that would take hundreds of lines of normal Python. That being said, Pandas isn't a very good array language. I really like kdb+/q and find it better and more expressive than almost any other language I've used.