Skip to content

CLN: _axis_len checking cleanup and better message #4855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _get_axis_number(self, axis):
return self._AXIS_NUMBERS[axis]
except:
pass
raise ValueError('No axis named %s' % axis)
raise ValueError('No axis named {0} for object type {1}'.format(axis,type(self)))

def _get_axis_name(self, axis):
axis = self._AXIS_ALIASES.get(axis, axis)
Expand All @@ -256,7 +256,7 @@ def _get_axis_name(self, axis):
return self._AXIS_NAMES[axis]
except:
pass
raise ValueError('No axis named %s' % axis)
raise ValueError('No axis named {0} for object type {1}'.format(axis,type(self)))

def _get_axis(self, axis):
name = self._get_axis_name(axis)
Expand Down Expand Up @@ -496,7 +496,7 @@ def rename_axis(self, mapper, axis=0, copy=True, inplace=False):
-------
renamed : type of caller
"""
axis = self._AXIS_NAMES[axis]
axis = self._get_axis_name(axis)
d = { 'copy' : copy, 'inplace' : inplace }
d[axis] = mapper
return self.rename(**d)
Expand Down Expand Up @@ -1546,9 +1546,6 @@ def fillna(self, value=None, method=None, axis=0, inplace=False,
self._consolidate_inplace()

axis = self._get_axis_number(axis)
if axis + 1 > self._AXIS_LEN:
raise ValueError(
"invalid axis passed for object type {0}".format(type(self)))
method = com._clean_fill_method(method)

if value is None:
Expand Down