What is the difference between single and double colon in this situation?
data[0:,4]
vs data[0::,4]
women_only_stats = data[0::,4]
Both syntaxes result in the same indexes.
class Foo(object):
def __getitem__(self, idx):
print(idx)
Foo()[1::,6]
# prints (slice(1, None, None), 6)
Foo()[1:,6]
# prints (slice(1, None, None), 6)
Basically, 1::,6
is a tuple of a slice (1::
) and a number (6
). The slice is of the form start:stop[:stride]
. Leaving the stride blank (1::
) or not stating it (1:
) is equivalent.