Numpy – add row to array
You can do this: newrow = [1, 2, 3] A = numpy.vstack([A, newrow])
You can do this: newrow = [1, 2, 3] A = numpy.vstack([A, newrow])
You can use the by() function: by(dataFrame, seq_len(nrow(dataFrame)), function(row) dostuff) But iterating over the rows directly like this is rarely what you want to; you should try to vectorize instead. Can I ask what the actual work in the loop is doing?
Well I found a much simplier way to do this, but you’ll need to set the line-height of the textarea in the CSS. I tried to read the line height inside the script ta.style.lineHeight but it doesn’t seem to return a value. CSS #ta { width: 300px; line-height: 20px; } HTML <textarea id=”ta”>Lorem ipsum dolor … Read more
This should do the trick: df[- grep(“REVERSE”, df$Name),] Or a safer version would be: df[!grepl(“REVERSE”, df$Name),]
Use rowSums. To remove rows from a data frame (df) that contain precisely n NA values: df <- df[rowSums(is.na(df)) != n, ] or to remove rows that contain n or more NA values: df <- df[rowSums(is.na(df)) < n, ] in both cases of course replacing n with the number that’s required
df <- data.frame(a = 1:2, b = letters[1:2]) df[rep(seq_len(nrow(df)), each = 2), ]
select distinct stuff(( select ‘,’ + u.username from users u where u.username = username order by u.username for xml path(”) ),1,1,”) as userlist from users group by username had a typo before, the above works
sqldf provides a nice solution a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) require(sqldf) a1NotIna2 <- sqldf(‘SELECT * FROM a1 EXCEPT SELECT * FROM a2’) And the rows which are in both data frames: a1Ina2 <- sqldf(‘SELECT * FROM a1 INTERSECT SELECT * FROM a2’) The new version of dplyr has … Read more