Skip to content
Advertisement

Confused on Index Slicing in python

I am slicing my hour column and when I use slice(1, 3) and slice(0, 3) I get the same results. What am i missing? See in the image below.

Original Column

slice(0, 3)

slice(1, 3)

Advertisement

Answer

There is a space at the beginning of dataset["hour"].

So slice(0, 3) is ” 02″ while slice(1, 3) is “02”.

This was answered by @Barmar on comment.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement