Skip to content

Series that used to be typed numeric is now typed 'object' #690

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

Closed
craustin opened this issue Jan 26, 2012 · 2 comments
Closed

Series that used to be typed numeric is now typed 'object' #690

craustin opened this issue Jan 26, 2012 · 2 comments
Labels
Milestone

Comments

@craustin
Copy link

import numpy as np
from pandas import Series
s = Series(range(3))
s2 = s.map(lambda x: np.where(x == 0, 0, 1))
print s2.dtype

In pandas 0.6.0, this returned 'float64', but now it returns 'object'. This change requires us to explicitly specify some dtypes to pandas constructors as a workaround. If this is the desired behavior, we can live with it - but wanted to alert you guys.

@wesm
Copy link
Member

wesm commented Jan 26, 2012

Well, a good question is, why are you doing that instead of np.where(s == 0, 0, 1)? Vectorization is good :)

Fixed this in the above commit (np.where called with a scalar results in 0-dimensional arrays, so I inserted a hack to "unbox" the value inside). However I would expect the result to be integer and not float (the current behavior).

@wesm wesm closed this as completed Jan 26, 2012
@craustin
Copy link
Author

I would expect integer as well. Thanks, Wes. Yes, the vector solution is much better.

yarikoptic added a commit to neurodebian/pandas that referenced this issue Feb 10, 2012
* commit 'v0.7.0rc1-73-g69d5bd8': (44 commits)
  BUG: integer slices should never access label-indexing, GH pandas-dev#700
  BUG: pandas-dev#680 clean up with check for py3compat
  BUG: pandas-dev#680 rears again. cut off another hydra head
  ENH: change to tree-like MultiIndex output with > 2 levels, GH pandas-dev#689
  TST: added a test related to pandas-dev#680
  BUG: related to closes pandas-dev#691, removed cruft
  BUG: closes pandas-dev#691, assignment with ix and mixed dtypes
  BUG: handle incomparable values when creating Factor, caused bug in py3
  TST: Fixes for tests on Python 3.
  BUG: pandas-dev#680, print consistently when dataframe is empty
  TST: unit test for PR pandas-dev#684
  ENH: Allow Series.to_csv to ignore the index.
  BUG: raise exception in DateRange with MonthEnd(0) instead of infinite loop, GH pandas-dev#683
  BUG: unbox 0-dimensional arrays in map_infer, GH pandas-dev#690
  updated license and credits for overview
  ENH: cythonize timestamp conversion in HDFStore
  TST: ok, this appears to work GH pandas-dev#680
  TST: even more woes GH pandas-dev#680
  TST: unicode woes on windoze GH pandas-dev#680
  TST: unicode codec test issue, GH pandas-dev#680
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants