wesm/pandas — Issue #763: possible error in mean of dataframe with nan values?
Author: CRP
Created: 2012-02-08 11:42:26+00:00
State: open

I am not sure if I am doing something wrong, but this looks like a bug to me:

In [116]: ra.ix[:5,:5]
Out[116]:
005665 023740 028758 040828 045449
2011-05-09 NaN NaN NaN NaN NaN
2011-05-10 -0.00284467268624 0.0 0.0 -0.002844627571 0.000353248710642
2011-05-11 -0.00674436854779 0.0 0.0 -0.00674432257973 0.0
2011-05-12 0.0117105570627 0.0 0.0 0.0117104073878 0.0
2011-05-13 0.00367090573068 0.0 0.0 -0.00102855609881 0.0

In [117]: ra.ix[:5,:5].mean(axis=0,skipna=True)
Out[117]:
005665 0.0014481
023740 0.0000000
028758 0.0000000
040828 0.0002732
045449 8.831e-05

In [118]: ra.ix[:5,:5].mean(axis=1,skipna=True)
Out[118]:
2011-05-09 NaN
2011-05-10 NaN
2011-05-11 NaN
2011-05-12 NaN
2011-05-13 NaN

In [122]: ra.ix[1:5,:5].mean(axis=1,skipna=True)
Out[122]:
2011-05-10 -0.0010672
2011-05-11 -0.0026977
2011-05-12 0.0046842
2011-05-13 0.0005285

In step 118, I would expect the same output I get at step 122. Maybe the check if values are all NaN on a given row are done on the wrong axis?