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

BUG: SparseDataFrame may not preserve passed dtype #13866

Merged
merged 1 commit into from Aug 3, 2016

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Aug 1, 2016

  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

SparseDataFrame may reset passed sparse data's dtype and fill_value as below.

on current master:

arr = pd.SparseArray([1, 0, 3, 0], dtype=np.int64, fill_value=0)

# OK, dtype and fill_value are kept
s = pd.SparseSeries(arr, name='x')
s.dtype, s.fill_value
(dtype('int64'), 0)

# NG, dtype is reset
df = pd.SparseDataFrame(s)
df['x'].dtype, df['x'].fill_value
(dtype('float64'), 0)

# NG, dtype is reset
df = pd.SparseDataFrame({'x': s})
df['x'].dtype, df['x'].fill_value
(dtype('float64'), 0)

# NG, dtype and fill_value are reset
df = pd.SparseDataFrame({'x': arr})
df['x'].dtype, df['x'].fill_value
(dtype('float64'), nan)

@sinhrks sinhrks added Bug Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type labels Aug 1, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Aug 1, 2016
@sinhrks sinhrks force-pushed the sparse_init_dtype branch 2 times, most recently from fc318b4 to 26109c1 Compare August 2, 2016 11:20
@codecov-io
Copy link

codecov-io commented Aug 2, 2016

Current coverage is 85.28% (diff: 100%)

Merging #13866 into master will decrease coverage by <.01%

@@             master     #13866   diff @@
==========================================
  Files           139        139          
  Lines         50011      50008     -3   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          42650      42647     -3   
  Misses         7361       7361          
  Partials          0          0          

Powered by Codecov. Last update 768bf49...dea69ed

@jreback jreback merged commit caf69d5 into pandas-dev:master Aug 3, 2016
@jreback
Copy link
Contributor

jreback commented Aug 3, 2016

thanks!

@sinhrks sinhrks deleted the sparse_init_dtype branch August 3, 2016 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants