0
Q:

list slicing in pandas

# [start:stop:step]
# for example ...
l = [1, 2, 3, 4, 5]
l[1:4] # elements from 1 (inclusive) to 4 (exclusive)
l[2:5:2] # elements from 2 (inclusive) to 5 (exclusive) going up by 2
2
sample_list = [1,2,3,4,5,6]
new_list = sample[1:4]
# index slicing using index
# print(new_list) = [2,3,4,5]
1
>>> nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]
>>> some_nums = nums[2:7]
>>> some_nums
[30, 40, 50, 60, 70
0

New to Communities?

Join the community