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 construction with lists not coercing to dtype #15682

Closed
jreback opened this issue Mar 14, 2017 · 2 comments
Closed

BUG: SparseDataFrame construction with lists not coercing to dtype #15682

jreback opened this issue Mar 14, 2017 · 2 comments
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Mar 14, 2017

coercion happens

In [12]: df = pd.SparseDataFrame({'a': [1, 0, 0],
    ...:                          'b': [0, 1, 0],
    ...:                          'c': [0, 0, 1]}, dtype='uint8', default_fill_value=0)

In [13]: df.dtypes
Out[13]: 
a    int64
b    int64
c    int64
dtype: object

respected here

In [23]: df = pd.SparseDataFrame({'a': pd.SparseSeries([1, 0, 0], dtype='uint8'),
    ...:                          'b': pd.SparseSeries([0, 1, 0], dtype='uint8'),
    ...:                          'c': pd.SparseSeries([0, 0, 1], dtype='uint8')}, default_fill_value=0)

In [24]: df.dtypes
Out[24]: 
a    uint8
b    uint8
c    uint8
dtype: object

In [25]: df.default_fill_value
Out[25]: 0

And here

In [15]: df = pd.DataFrame({'a': [1, 0, 0],
    ...:                          'b': [0, 1, 0],
    ...:                          'c': [0, 0, 1]}, dtype='uint8').to_sparse(fill_value=0)

In [17]: df.dtypes
Out[17]: 
a    uint8
b    uint8
c    uint8
dtype: object

In [18]: df.default_fill_value
Out[18]: 0
@jreback jreback added Bug Difficulty Intermediate Dtype Conversions Unexpected or buggy dtype conversions Sparse Sparse Data Type labels Mar 14, 2017
@jreback jreback added this to the 0.20.0 milestone Mar 14, 2017
@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 23, 2017
@ucals
Copy link

ucals commented Mar 28, 2017

As the last one we did was about types, I'd like to try this one :)

@jreback
Copy link
Contributor Author

jreback commented Mar 28, 2017

@ucals sure!

@jreback jreback modified the milestones: 0.20.0, Next Major Release Mar 30, 2017
mattip pushed a commit to mattip/pandas that referenced this issue Apr 3, 2017
…H 15682)

closes pandas-dev#15682

Author: Carlos Souza <carlos@udacity.com>

Closes pandas-dev#15834 from ucals/bug-fix-15682 and squashes the following commits:

04fba8d [Carlos Souza] Adding test_rename test cases (were missing)
483bb2c [Carlos Souza] Doing adjustments as per @jreback requests
cc4c15b [Carlos Souza] Fixing coersion bug at SparseDataFrame construction
faa5c5c [Carlos Souza] Merge remote-tracking branch 'upstream/master'
43456a5 [Carlos Souza] Merge remote-tracking branch 'upstream/master'
8b463cb [Carlos Souza] Merge remote-tracking branch 'upstream/master'
9fc617b [Carlos Souza] Merge remote-tracking branch 'upstream/master'
e12bca7 [Carlos Souza] Sync fork
676a4e5 [Carlos Souza] Test
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 a pull request may close this issue.

2 participants