Skip to content

Update SparseDtype user guide doc #35837

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

Merged
merged 3 commits into from
Aug 31, 2020
Merged

Update SparseDtype user guide doc #35837

merged 3 commits into from
Aug 31, 2020

Conversation

dsaxton
Copy link
Member

@dsaxton dsaxton commented Aug 21, 2020

Tiny doc nit. The doc says you can pass both dtype and fill_value to SparseDtype then only passes one in the example.

@mroeschke mroeschke added this to the 1.2 milestone Aug 22, 2020
@mroeschke mroeschke added Docs Sparse Sparse Data Type labels Aug 22, 2020
@MarcoGorelli
Copy link
Member

The user guide already shows an example on the next line of passing a fill value though - perhaps, instead of making both examples pass a fill value, the wording could be changed so that the first example shows construction with just the dtype of the non-sparse values. Something like

A :class:`SparseDtype` may be constructed by passing the former

.. ipython:: python
   pd.SparseDtype(np.dtype('datetime64[ns]'))

, in which case the default fill value for a given NumPy dtype is the "missing" value for that dtype. Note that it may be overridden by passing a `fill_value`, for example

.. ipython:: python
   pd.SparseDtype(np.dtype('datetime64[ns]'),
                  fill_value=pd.Timestamp('2017-01-01'))

@dsaxton
Copy link
Member Author

dsaxton commented Aug 23, 2020

Good point @MarcoGorelli. Actually I changed some other wording as well (it's not entirely true that a missing value indicator will be used for numpy dtypes, e.g., not for integers)

In [1]: import numpy as np                                                                                                                                                                                   

In [2]: import pandas as pd                                                                                                                                                                                  

In [3]: pd.SparseDtype(np.int64)                                                                                                                                                                             
Out[3]: Sparse[int64, 0]

@mroeschke mroeschke merged commit 54ce729 into pandas-dev:master Aug 31, 2020
@mroeschke
Copy link
Member

Thanks @dsaxton. The CI failure was unrelated

Skipping uploading of coverage data.

=================================== ERRORS ====================================
_____ ERROR at setup of TestParquetPyArrow.test_s3_roundtrip_explicit_fs ______

@dsaxton dsaxton deleted the sparse-doc branch August 31, 2020 18:47
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Aug 31, 2020
* Update SparseDtype user guide doc

* Reword
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
* Update SparseDtype user guide doc

* Reword
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Sparse Sparse Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants