def make_sparse(arr, kind='<STR_LIT>', fill_value=None, dtype=None, copy=False):
arr = _sanitize_values(arr)<EOL>if arr.ndim > <NUM_LIT:1>:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if fill_value is None:<EOL><INDENT>fill_value = na_value_for_dtype(arr.dtype)<EOL><DEDENT>if isna(fill_value):<EOL><INDENT>mask = notna(arr)<EOL><DEDENT>else:<EOL><INDENT>if is_string_dtype(arr):<EOL><INDENT>arr = arr.astype(object)<EOL><DEDENT>if is_object_dtype(arr.dtype):<EOL><INDENT>mask = splib.make_mask_object_ndarray(arr, fill_value)<EOL><DEDENT>else:<EOL><INDENT>mask = arr != fill_value<EOL><DEDENT><DEDENT>length = len(arr)<EOL>if length != len(mask):<EOL><INDENT>indices = mask.sp_index.indices<EOL><DEDENT>else:<EOL><INDENT>indices = mask.nonzero()[<NUM_LIT:0>].astype(np.int32)<EOL><DEDENT>index = _make_index(length, indices, kind)<EOL>sparsified_values = arr[mask]<EOL>if dtype is not None:<EOL><INDENT>sparsified_values = astype_nansafe(sparsified_values, dtype=dtype)<EOL><DEDENT>return sparsified_values, index, fill_value<EOL>
Convert ndarray to sparse format

Parameters
----------
arr : ndarray
kind : {'block', 'integer'}
fill_value : NaN or another value
dtype : np.dtype, optional
copy : bool, default False

Returns
-------
(sparse_values, index, fill_value) : (ndarray, SparseIndex, Scalar)