Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Score of 4708
38 answers
3271049 views

How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? See Why are slice and range upper-bound ...
Score of 30
11 answers
10203 views

This problem is also known as 'transforming a "start-end" dataset to a panel dataset' I have a data frame containing "name" of U.S. Presidents, the years when they start and end in ...
Score of 208
18 answers
783319 views

In PostgreSQL, I can do something like this: ALTER SEQUENCE serial RESTART WITH 0; Is there an Oracle equivalent?
Score of 22
5 answers
6224 views

I have a vector, such as c(1, 3, 4, 5, 9, 10, 17, 29, 30) and I would like to group together the 'neighboring' elements that form a regular, consecutive sequence, i.e. an increase by 1, in a ragged ...
Score of 32
8 answers
22385 views

The implicit conversion of a Python sequence of variable-length lists into a NumPy array cause the array to be of type object. v = [[1], [1, 2]] np.array(v) >>> array([[1], [1, 2]], dtype=...
Score of 42
1 answer
18026 views

I'm moving from MySql to Postgres, and I noticed that when you delete rows from MySql, the unique ids for those rows are re-used when you make new ones. With Postgres, if you create rows, and delete ...
Score of 172
22 answers
192531 views

Is it possible to use a DB sequence for some column that is not the identifier/is not part of a composite identifier? I'm using hibernate as jpa provider, and I have a table that has some columns ...
Score of 155
17 answers
126978 views

With the new range-based for-loop we can write code like: for(auto x: Y) {} Which IMO is a huge improvement from (for ex.) for(std::vector<int>::iterator x=Y.begin(); x!=Y.end(); ++x) {} Can ...
Score of 162
7 answers
229861 views

Data: df <- data.frame( type = c("T", "F", "P", "T", "F", "P", "T", "F", "P", "T", "F&...
Score of 29
3 answers
32549 views

I wish to create a sequential number within each run of equal values, like a counter of occurrences, which restarts once the value in the current row is different from the previous row. Please find ...
Score of 73
7 answers
110795 views

Is it possible to do something like this: start=1 end=10 echo {$start..$end} # Ouput: {1..10} # Expected: 1 2 3 ... 10 (echo {1..10})
Score of 108
3 answers
185867 views

I need a sequence of repeated numbers, i.e. 1 1 ... 1 2 2 ... 2 3 3 ... 3 etc. The way I implemented this was: nyear <- 20 names <- c(rep(1,nyear),rep(2,nyear),rep(3,nyear),rep(4,nyear), ...
Score of 46
7 answers
251017 views

I'm trying to create a sequence in MySQL (I'm very new to SQL as a whole). I'm using the following code, but it causes an error: CREATE SEQUENCE ORDID INCREMENT BY 1 START WITH 622; ORDID refers to a ...
Score of 126
9 answers
600103 views

I have the data.frame below. I want to add a column 'g' that classifies my data according to consecutive sequences in column h_no. That is, the first sequence of h_no 1, 2, 3, 4 is group 1, the second ...
Score of 6
1 answer
18590 views

I am trying to obtain a sequence within category. My data are: A B 1 1 1 2 1 2 1 3 1 3 1 3 1 4 1 4 and I want to get variable "c" such as my data look like: A B C 1 1 1 1 2 1 1 2 2 1 3 1 1 3 2 1 ...

15 30 50 per page
1
2 3 4 5
56