for-loop

R timestamp with iteration for Machine Learning- 30 minute window

馋奶兔 提交于 2020-01-07 03:49:35
问题 I have a data frame with a timestamp column (converted to real time) that looks like this (only a small portion is shown): "2016-05-25 08:59:21 EDT" "2016-05-25 08:59:21 EDT" "2016-05-25 08:59:21 EDT" "2016-05-25 08:59:22 EDT" "2016-05-25 09:39:57 EDT" "2016-05-25 09:40:33 EDT" (Of course, there are other columns that are adjacent to the timestamp column.) What I want to achieve is...to divide all the data into 30 minute sections. So, I want all the data between 08:59:00 ~ 09:29:00 grouped

for loop to create a matrix in python

对着背影说爱祢 提交于 2020-01-07 03:47:20
问题 I am trying to study the probability of having a zero value in my data and I have developed a code that outputs the value of a column of data when the other is zero which is what I need. But having to do that for each column vs all other 28 of my 577by29 dataframe is difficult so I decided to create a for loop that does that for me where I have this: import numpy as np import pandas as pd allchan = pd.read_csv('allchan.csv',delimiter = ' ') allchanarray = np.array(allchan) dfallchan = pd

Speed up R script looping through files/folders to check thresholds, calculate averages, and plot

自古美人都是妖i 提交于 2020-01-07 03:10:29
问题 I'm trying to speed up some code in R. I think my looping methods can be replaced (maybe with some form of lapply or using sqldf) but I can't seem to figure out how. The basic premise is that I have a parent directory with ~50 subdirectories, and each of those subdirectories contains ~200 CSV files (a total of 10,000 CSVs). Each of those CSV files contains ~86,400 lines (data is daily by the second). The goal of the script is to calculate the mean and stdev for two intervals of time from each

OpenMP to CUDA: Reduction

时光毁灭记忆、已成空白 提交于 2020-01-07 02:37:28
问题 I'm trying to figure out how I can use OpenMP's for reduction() equivalent in CUDA. I've done some research online, and none of what I've tried worked. The code: #pragma omp parallel for reduction(+:sum) for (i = 0; i < N; i++) { float f = ... //store return from function to f out[i] = f; //store f to out[i] sum += f; //add f to sum and store in sum } I know what for reduction() does in OpenMP....it makes the last line of the for loop possible. But how can I use CUDA to express the same thing

Batch-Loop that opens fixed length filenames in subdirectories

回眸只為那壹抹淺笑 提交于 2020-01-07 02:01:31
问题 I got this far into making a code (with you guys help on here) but it doesn't do what it's supposed to do.. The goal of the batch is to open all K_E*.dwg files and execute a script on those. The length of the K_E*.dwg files should be 9. Example K_E123456.dwg. So far, this code opens a dos-window and closes it again.. my folders structure is like this : C:\Users\b00m49\Desktop\LSPTEST\0031\00\K_E000031.dwg C:\Users\b00m49\Desktop\LSPTEST\0031\01\K_E010031.dwg C:\Users\b00m49\Desktop\LSPTEST

Using forloop to populate brackets

主宰稳场 提交于 2020-01-07 01:58:26
问题 I want to learn to use for loop to populate brackets such as the following:- $max starts at 8 and can be maximum of 512. I only know very basics of forloop, not too well to form the below brackets.. can someone help me on this and explain how they done it. Each goes into simple pattern/sequence. I appreciate it very much. $max = 8; if($max == 8) [[0, 0], [0, 0]], [[0, 0], [0, 0]], [[0, 0]], [[0, 0]] if($max == 16) [[0,0], [0,0], [0,0], [0,0]], [[0,0], [0,0], [0,0], [0,0]], [[0,0], [0,0]], [[0

Need to vectorize solution that using nested loops (transform data frame from long to wide format)

浪子不回头ぞ 提交于 2020-01-06 21:45:08
问题 I have following data frame and need to do transformation from long into wide format: symbol side price 1 A B 1 2 A S 2 3 B B 3 4 C B 4 5 B S 5 Explanation: for every symbol must exists two lines with side B and side S. Need to find these lines and transform them into wide format: [symbol, first-comed side (B or S), price of side B, price of side S] If one line exists but another is missing, then put NA value to appropriate price value. For example if line with side B exists, but with side S

Need to vectorize solution that using nested loops (transform data frame from long to wide format)

若如初见. 提交于 2020-01-06 21:44:46
问题 I have following data frame and need to do transformation from long into wide format: symbol side price 1 A B 1 2 A S 2 3 B B 3 4 C B 4 5 B S 5 Explanation: for every symbol must exists two lines with side B and side S. Need to find these lines and transform them into wide format: [symbol, first-comed side (B or S), price of side B, price of side S] If one line exists but another is missing, then put NA value to appropriate price value. For example if line with side B exists, but with side S

How to iterate over functions?

南笙酒味 提交于 2020-01-06 21:23:48
问题 I would like to apply loop over a function. I have the following "mother" code: v = 1; fun = @root; x0 = [0,0] options = optimset('MaxFunEvals',100000,'MaxIter', 10000 ); x = fsolve(fun,x0, options) In addition, I have the following function in a separate file: function D = root(x) v = 1; D(1) = x(1) + x(2) + v - 2; D(2) = x(1) - x(2) + v - 1.8; end Now, I would like to find roots when v = sort(rand(1,1000)) . In other words, I would like to iterate over function for each values of v . 回答1:

Delay for loop cycle in Java

不打扰是莪最后的温柔 提交于 2020-01-06 20:21:39
问题 I am building an SMS messaging app, with a list of phone numbers in an array which I would like to send to. When I press the SEND button in the app, the message that I type would be sent to all the numbers in that array. I am using a for loop to run through the numbers and sending the same message to each of them: for (i=0; i<names.length; i++) { phoneNo = names[i][3]; sendMessage(phoneNo, message); } private void sendMessage(String phoneNo, String message) { try { SmsManager smsManager =