The "logical indexing" version of that would be f = Dstc["time"][i] .<= Dstr["time"] .< Dstc["time"][i+1] dN = Dstr["NH3"][f]
In other words dropping the "find" and using a boolean array (BitArray) to do the indexing. In Matlab this is usually faster, not sure whether the same speed comparison translates to Julia. Then also you'd need to change to Dstr2[i,1] = findfirst(f) On Wednesday, April 16, 2014 2:08:31 AM UTC-7, RecentConvert wrote: > > Is there a faster way of doing this? > > Dstr2 = Array(Float64,length(Dstc["time"])-1,2) # Preallocate averaged > Dstr array > for i=1:1:length(Dstc["time"]) - 1 > f = find(Dstc["time"][i] .<= Dstr["time"] .< Dstc["time"][i+1]) > dN = Dstr["NH3"][f] > > Dstr2[i,1] = f[1] > Dstr2[i,2] = mean(dN) > end > > > Dstr and Dstc are both dataframes. >
