BUG: SparseDataFrame may not preserve passed dtype #13866

Merged
merged 1 commit into from Aug 3, 2016

Conversation

Projects
None yet
3 participants
Member

sinhrks commented Aug 1, 2016 edited

  • 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 added this to the 0.19.0 milestone Aug 1, 2016

codecov-io commented Aug 2, 2016 edited

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

@sinhrks sinhrks BUG: SparseDataFrame may not preserve passed dtype
dea69ed

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

3 checks passed

codecov/patch 100% of diff hit (target 50.00%)
Details
codecov/project 85.28% (target 82.00%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Contributor

jreback commented Aug 3, 2016

thanks!

sinhrks deleted the sinhrks:sparse_init_dtype branch Aug 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment