Skip to content

np.fix doesn't work #8

Closed
Closed
@andylei

Description

@andylei
In [28]: np.fix(Series([1,2,3], range(3)))
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)

C:\alei1\basic_mktneutral\<ipython console> in <module>()

C:\Python26\lib\site-packages\numpy\lib\ufunclike.pyc in fix(x, y)
     43     x = nx.asanyarray(x)
     44     if y is None:
---> 45         y = nx.zeros_like(x)
     46     y1 = nx.floor(x)
     47     y2 = nx.ceil(x)

C:\Python26\lib\site-packages\numpy\core\numeric.pyc in zeros_like(a)
     92     if isinstance(a, ndarray):
     93         res = ndarray.__new__(type(a), a.shape, a.dtype, order=a.flags.fnc)
---> 94         res.fill(0)
     95         return res
     96     try:

C:\Python26\lib\site-packages\pandas\core\series.pyc in fill(self, value, method)
    822         """
    823         if value is not None:
--> 824             newSeries = self.copy()
    825             newSeries[isnull(newSeries)] = value
    826             return newSeries

C:\Python26\lib\site-packages\pandas\core\series.pyc in copy(self)
    342
    343     def copy(self):
--> 344         return Series(self.values.copy(), index=self.index)
    345
    346 #-------------------------------------------------------------------------------


C:\Python26\lib\site-packages\pandas\core\series.pyc in __new__(cls, data, index, dtype, copy)
    136
    137         if index is None:
--> 138             raise Exception('Index cannot be None!')
    139
    140         # This is to prevent mixed-type Series getting all casted to

i think the bigger problem is overriding the default behavior of the fill() method, which may contribute to other numpy / scipy functions not behaving correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions