rows

Comparing values of a certain row with a certain number of previous rows in data.table

陌路散爱 提交于 2020-08-05 10:11:46
问题 This is an extension of this question asked before. In a database containing firm and category values, I want to calculate this: If a firm enters into a new category that it has not been previously engaged in Three(3) previous years (not including the same year), then that entry is labeld as "NEW", otherwise it will be labeld as "OLD". In the following dataset: df <- data.table(year=c(1979,1979,1980,1980,1981,1981,1982,1983,1983,1984,1984), category = c("A","A","B","C","A","D","F","F","C","A"

R - How to delete rows before a certain phrase and after a certain phrase in a single column

谁都会走 提交于 2020-06-28 05:11:37
问题 Hi I would like to delete rows before a certain phrase and then after the same (almost) phrase which appears later on. I guess another way to look at it would be keep only the data from the start and end of a certain section. My data is as follows: df <- data.frame(time = as.factor(c(1,2,3,4,5,6,7,8,9,10,11,12,13)), type = c("","","GMT:yyyy-mm-dd_HH:MM:SS_LT:2016-10-18_06:09:53","(K)","","","","(K)","(K)","","(K)","GMT:yyyy-mm-dd_HH:MM:SS_CAM:2016-10-18_06:20:03",""), names = c("J","J","J","J

R - All pairwise combinations of column strings concatenated by the row

亡梦爱人 提交于 2020-06-16 04:05:31
问题 How can I transform data frames like this one: X__1 X__2 X__3 <chr> <chr> <chr> 1 a b c 2 d e f 3 g h i 4 j k l Into this one: X__1 X__2 X__3 <chr> <chr> <chr> 1 a-d b-e c-f 2 a-g b-h c-i 3 a-j b-k c-l 4 d-g e-h f-i 5 d-j e-k f-l 6 g-j h-k i-l In other words, it should make all possible pairwise combinations of the whole rows in the data frame, combining strings from the same column but separated by a sign(-). It does not need to repeat an already made combination in the other order of

Laravel insert or update multiple rows

别来无恙 提交于 2020-05-25 04:44:05
问题 Im new in laravel, and im trying to update my navigation tree. So i want to update my whole tree in one query without foreach. array( array('id'=>1, 'name'=>'some navigation point', 'parent'='0'), array('id'=>2, 'name'=>'some navigation point', 'parent'='1'), array('id'=>3, 'name'=>'some navigation point', 'parent'='1') ); I just want to ask - is there posibility in laravel to insert(if new in array) or update my current rows in database? I want to update all, because i have fields _lft,

Extract rows between two specific cells pandas

我是研究僧i 提交于 2020-05-23 21:12:27
问题 I need to extract n rows between the cells epic and story from the column col2 . This is my input: import pandas as pd df = pd.DataFrame({'col1': ['aze ', 'az a', 'az a', 'azs abv','aze ', 'az a', 'azs abv', 'abc 45','wqas', 'foo bar abc', 'foo abv', 'abc 45', 'abc 45'], 'col2': ['epic', 'ac4', 'ac5', 'story','story', 'ac10', 'ac6', 'epic','ac11', 'ac1', 'ac2', 'ac3', 'story'], 'col3': ['hey', 'hello', 'hola', 'yoopy','hawdi', 'yiiha', 'yow', 'yalla', 'yiiha', 'yow', 'yalla', 'yalla', 'yalla'

Insert Specific Number of Rows

我的未来我决定 提交于 2020-05-13 18:19:09
问题 I'm trying to insert a specific number of rows. Right now I'm using the below code to insert 4 lines. I'm trying to write a line of code that will insert a certain number or rows based on a number in a certain cell. For example, if I wanted to insert 4 rows and cell A2 is the cell where I can change the number of rows I want to add, what code would I use to add any number of rows based off what number I insert in cell A2. ActiveCell.EntireRow.Select Selection.Insert Shift:=xlDown Selection

Insert Specific Number of Rows

穿精又带淫゛_ 提交于 2020-05-13 18:18:43
问题 I'm trying to insert a specific number of rows. Right now I'm using the below code to insert 4 lines. I'm trying to write a line of code that will insert a certain number or rows based on a number in a certain cell. For example, if I wanted to insert 4 rows and cell A2 is the cell where I can change the number of rows I want to add, what code would I use to add any number of rows based off what number I insert in cell A2. ActiveCell.EntireRow.Select Selection.Insert Shift:=xlDown Selection