4 ms·
But why design it that way? Seems to be a sure way to confuse new user.
by yufeng66 8y ago
But why design it that way? Seems to be a sure way to confuse new user.
- EForEndeavour 8y agoI'd say that's because df[start:stop] mimics python's builtin list slicing, which includes start but excludes end, so this dictates the behaviour of indexing without .loc. By contrast, df.loc[start:stop] is a label-based indexer, and labels can be anything (integers, strings, datetimes, categories, etc.), so it doesn't always make sense to exclude the right endpoint of the interval.