An ExtensionArray for storing sparse data.
A dense array of values to store in the SparseArray. This may contain fill_value.
Elements in data that are fill_value
are not stored in the SparseArray. For memory savings, this should be the most common value in data. By default, fill_value depends on the dtype of data:
data.dtype
na_value
float
np.nan
int
0
bool
False
datetime64
pd.NaT
timedelta64
pd.NaT
The fill value is potentially specified in three ways. In order of precedence, these are
The fill_value argument
dtype.fill_value
if fill_value is None and dtype is a SparseDtype
data.dtype.fill_value
if fill_value is None and dtype is not a SparseDtype
and data is a SparseArray
.
Can be âintegerâ or âblockâ, default is âintegerâ. The type of storage for sparse locations.
âblockâ: Stores a block and block_length for each contiguous span of sparse values. This is best when sparse data tends to be clumped together, with large regions of fill-value
values between sparse values.
âintegerâ: uses an integer to store the location of each sparse value.
The dtype to use for the SparseArray. For numpy dtypes, this determines the dtype of self.sp_values
. For SparseDtype, this determines self.sp_values
and self.fill_value
.
Whether to explicitly copy the incoming data array.
Attributes
Methods
Examples
>>> from pandas.arrays import SparseArray >>> arr = SparseArray([0, 0, 1, 2]) >>> arr [0, 0, 1, 2] Fill: 0 IntIndex Indices: array([2, 3], dtype=int32)
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