Issue
I have the following start and end values:
start = 0
end = 54
I need to generate subsets of 4 sequential integers starting from start
until end
with a space of 20 between each subset. The result should be this one:
0, 1, 2, 3, 24, 25, 26, 27, 48, 49, 50, 51
In this example, we obtained 3 subsets:
0, 1, 2, 3
24, 25, 26, 27
48, 49, 50, 51
How can I do it using numpy
or pandas
?
If I do r = [i for i in range(0,54,4)]
, I get [0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52]
.
Solution
Maybe something like this:
r = [j for i in range(0, 54, 24) for j in range(i, i + 4)]
print(r)
[0, 1, 2, 3, 24, 25, 26, 27, 48, 49, 50, 51]
Answered By - AloneTogether
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.