Questions tagged [sequential-number]
50 questions
5
votes
1 answer
Numpy: populate a 2D numpy array with sequential integers
Say you want to create a 2D numpy array, and want to populate it with sequential integers. What are the options available?
Example:
import numpy
a=numpy.array([[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14]])
In this case of course I could use range(15)…

FaCoffee
- 7,609
- 28
- 99
- 174
4
votes
4 answers
How to create sequential number column in pyspark dataframe?
I would like to create column with sequential numbers in pyspark dataframe starting from specified number. For instance, I want to add column A to my dataframe df which will start from 5 to the length of my dataframe, incrementing by one, so 5, 6,…

max04
- 5,315
- 3
- 13
- 21
3
votes
2 answers
How can I rename files by prepending a sequence number to the original file names?
guys does anyone know how can i do this? I am trying to list some files in a numerical order by adding 1, 2, 3 and so on to the beginning of the file names while also keeping the files' original names.
Here are the codes i tried
$nr = 1
Dir -path…

Burak Yazıcı
- 33
- 3
3
votes
3 answers
dplyr: Mutate a new column with sequential repeated integers of n time in a dataframe
I am struggling with one maybe easy question. I have a dataframe of 1 column with n rows (n is a multiple of 3). I would like to add a second column with integers like: 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,.. How can I achieve this with dplyr as a general…

TarJae
- 72,363
- 6
- 19
- 66
3
votes
2 answers
Trouble outputting full list of numbers using innerHTML
the following is code to create a sequential list of numbers from 1 to 10. I'd like to take this list and output in the div "pagination" using innerHTML. However, when I execute the script, the only thing that is outputted is the number 10. When…

Choy
- 2,087
- 10
- 37
- 48
2
votes
2 answers
count successive occurences in a time series without df.iterrows()
Given a dataframe with a time series like this:
time
event
2020-01-01 12:00:00
1
2020-01-01 12:00:01
NaN
2020-01-01 12:00:02
1
2020-01-01 12:00:03
1
2020-01-01 12:00:04
NaN
2020-01-01 12:00:05
NaN
2020-01-01…

Kris De Beleir
- 47
- 4
2
votes
7 answers
Windows/C# system-level sequential number generator?
Is there a managed system-level sequential number generator? DateTime.Now.Ticks won't do because the operations I'm doing sometimes occur more than once per tick.
Requirement Clarifications:
Process agnostic - there's really only one process that…

Daniel Schaffer
- 56,753
- 31
- 116
- 165
2
votes
5 answers
How to join sequential numbers to unrelated data (SQL Server)
This question is a followup to a previous question I had about discovering unused sequential number ranges without having to resort to cursors (Working with sequential numbers in SQL Server 2005 without cursors). I'm using SQL Server 2005.
What I…

enriquein
- 1,048
- 1
- 12
- 28
2
votes
1 answer
SQL Server Order By GroupID Random but asc ID in each GroupID
I'm using SQL Server 2012.
I want to set sequential numbers to Num field each time I execute the SQL with the rules as follows:
Grp order to be randomized.
ID field to be ascended.
Could anyone shed some light for me?
TABLE
…

Hanericka
- 59
- 7
1
vote
1 answer
Update SQL with consecutive numbering within a group
I found the technique to update rows of a table with consecutive numbers here:
Update SQL with consecutive numbering
The gist of the technique is to use (T-SQL):
update myTable
SET @myvar = myField = @myVar + 1
which is awesome and works very…

unubar
- 416
- 6
- 15
1
vote
3 answers
Optimize loop for index creation in R
I have a dataframe with records of trawl stations in different regions. I need to create a sequential index that changes every time the region changes. I've implemented it with a for loop, but I have about 60000 records, so it's super slow. Any idea…

Piera
- 75
- 5
1
vote
0 answers
PowerShell - Rename files with number prefix
I have the following code:
$FilesFolder = "$env:USERPROFILE\Desktop\FilesToRename"
foreach($item in $FilesFolder)
{
Get-ChildItem $FilesFolder | Rename-Item -NewName { "Test - " + $_.Name }
}
It's a simple code, basically it adds the prefix Test - …

Tyrone Hirt
- 341
- 1
- 8
1
vote
4 answers
Print the missing number in a unique sequential list with an arbitrary starting range or starting from 1
This question is similar to How can I find the missing integers in a unique and sequential list (one per line) in a unix terminal?.
The difference being is that I want to know if it is possible to specify a starting range to the list
I have noted…

benbart
- 23
- 4
1
vote
1 answer
How to generate sequential string names like "account1", "account2" if that particular account name already exists
I have a requirement that states the following:
"The system shall verify if the username from the imported file is already in use, and shall generate the username according to the duplicate format
Example: If username suesmith is in use, the system…

Alex
- 57
- 1
- 5
1
vote
2 answers
How do I use SQL to sequentially number events based on event type?
I am trying to figure out the number of days something occurred for each "event type." For example, I have several users, several event types and dates. I want to add a column for the "Days Since Last Event" (see image). What is the SQL syntax for…

stephanieseayrad
- 17
- 2