A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/15682 below:

SparseDataFrame construction with lists not coercing to dtype · Issue #15682 · pandas-dev/pandas · GitHub

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4