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/10648 below:

to_dense does not preserve dtype in SparseArray · Issue #10648 · pandas-dev/pandas · GitHub

This isn't a huge deal, but it seems a little odd:

In [1]: import pandas as pd

In [2]: a = pd.SparseArray([True, False, False, False, True], fill_value=False, dtype=bool)

In [3]: a
Out[3]: 
[True, False, False, False, True]
Fill: False
IntIndex
Indices: array([0, 4], dtype=int32)

In [4]: a.dtype
Out[4]: dtype('bool')

In [5]: d = a.to_dense()

In [6]: d
Out[6]: array([ 1.,  0.,  0.,  0.,  1.])

In [7]: d.dtype
Out[7]: dtype('float64')

I would have expected d to retain the dtype of bool. I can cast down, but I am still wasting 7 bytes per element in the process.


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