Skip to content
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

np.fix doesn't work #8

Closed
andylei opened this issue Sep 29, 2010 · 3 comments · Fixed by #52752
Closed

np.fix doesn't work #8

andylei opened this issue Sep 29, 2010 · 3 comments · Fixed by #52752
Labels

Comments

@andylei
Copy link

andylei commented Sep 29, 2010

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.

@wesm
Copy link
Member

wesm commented Sep 30, 2010

In principle I agree with you that fill should be renamed to something like fillna or fill_missing since a portion of the NumPy API relies on the fill function. Unfortunately changing it would definitely cause downstream breakage in the next release-- as far as API changes go it's not too terrible to go through and fix client code but it sucks.

@wesm
Copy link
Member

wesm commented Mar 1, 2011

I took a look at fixing this behavior-- I'm going to remove the overridden fill() function from Series, having created fillna functions in all of the classes. There actually is a bug in NumPy which has been fixed about a month ago-- so starting with NumPy 1.6 this can be fixed:

http://projects.scipy.org/numpy/ticket/929

@wesm
Copy link
Member

wesm commented Jun 23, 2011

{Series, DataFrame, WidePanel}.fill have been removed. So np.fix should work on NumPy >= 1.6 (does not work with 1.5.1, though)

@wesm wesm closed this as completed Jun 23, 2011
mroeschke pushed a commit that referenced this issue Dec 28, 2018
#21401)

* ENH: to_sql() add parameter "method" to control insertions method (#8953)

* ENH: to_sql() add parameter "method". Fix docstrings (#8953)

* ENH: to_sql() add parameter "method". Improve docs based on reviews (#8953)

* ENH: to_sql() add parameter "method". Fix unit-test (#8953)

* doc clean-up

* additional doc clean-up

* use dict(zip()) directly

* clean up merge

* default --> None

* Remove stray default

* Remove method kwarg

* change default to None

* test copy insert snippit

* print debug

* index=False

* Add reference to documentation
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this issue Dec 29, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
…ndas-dev#8… (pandas-dev#21401)

* ENH: to_sql() add parameter "method" to control insertions method (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Fix docstrings (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Improve docs based on reviews (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Fix unit-test (pandas-dev#8953)

* doc clean-up

* additional doc clean-up

* use dict(zip()) directly

* clean up merge

* default --> None

* Remove stray default

* Remove method kwarg

* change default to None

* test copy insert snippit

* print debug

* index=False

* Add reference to documentation
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
…ndas-dev#8… (pandas-dev#21401)

* ENH: to_sql() add parameter "method" to control insertions method (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Fix docstrings (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Improve docs based on reviews (pandas-dev#8953)

* ENH: to_sql() add parameter "method". Fix unit-test (pandas-dev#8953)

* doc clean-up

* additional doc clean-up

* use dict(zip()) directly

* clean up merge

* default --> None

* Remove stray default

* Remove method kwarg

* change default to None

* test copy insert snippit

* print debug

* index=False

* Add reference to documentation
dimastbk pushed a commit to dimastbk/pandas that referenced this issue Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants