Is there a way to access an iteration-counter in Java’s for-each loop?

Is there a way in Java’s for-each loop for(String s : stringArray) { doSomethingWith(s); } to find out how often the loop has already been processed? Aside from using the old and well-known for(int i=0; i < boundary; i++) – loop, is the construct int i = 0; for(String s : stringArray) { doSomethingWith(s); i++; … Read more

What is the most efficient way to loop through dataframes with pandas?

I want to perform my own complex operations on financial data in dataframes in a sequential manner. For example I am using the following MSFT CSV file taken from Yahoo Finance: Date,Open,High,Low,Close,Volume,Adj Close 2011-10-19,27.37,27.47,27.01,27.13,42880000,27.13 2011-10-18,26.94,27.40,26.80,27.31,52487900,27.31 2011-10-17,27.11,27.42,26.85,26.98,39433400,26.98 2011-10-14,27.31,27.50,27.02,27.27,50947700,27.27 …. I then do the following: #!/usr/bin/env python from pandas import * df = read_csv(‘table.csv’) for i, row … Read more