wesm/pandas — Issue #722: Exception from Series.mean()
Author: philbigdog
Created: 2012-01-31 08:35:47+00:00
State: open

In certain circumstances I found the following exception was raised when calling series.mean():
I'm running pandas 0.6.0. (I also checked the latest build on GitHub just in case!)

File "C:/Work/PyCharm/EPD-7.2.1/python/bin/heatmap.py", line 166, in zscore
logger.debug('b:{}'.format(series.mean()))
File "C:\Python27\lib\site-packages\pandas\core\series.py", line 650, in mean
return nanops.nanmean(self.values, skipna=skipna)
File "C:\Python27\lib\site-packages\pandas\core\nanops.py", line 30, in nanmean
the_mean = values.sum(axis) / float(values.shape[axis])
TypeError: tuple indices must be integers, not NoneType

The axis parameter is not being handed to nanops.nanmean(), where it is used for indexing.
So I changed (series.py line 650):
return nanops.nanmean(self.values, skipna=skipna)
to:
return nanops.nanmean(self.values, skipna=skipna, axis=axis)
to fix my code.