Skip to content

Commit a090024

Browse files
author
Chang She
committed
Merge pull request #2231 from justincjohnson/master
BUG: Incorrect error message due to zero based levels. #2226
2 parents 2d576ee + a72d886 commit a090024

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pandas/core/index.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,10 @@ def _get_level_number(self, level):
13641364
raise Exception('Level %s not found' % str(level))
13651365
elif level < 0:
13661366
level += self.nlevels
1367+
# Note: levels are zero-based
13671368
elif level >= self.nlevels:
13681369
raise ValueError('Index has only %d levels, not %d'
1369-
% (self.nlevels, level))
1370+
% (self.nlevels, level + 1))
13701371
return level
13711372

13721373
_tuples = None

0 commit comments

Comments
 (0)