-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: SparseDataFrame does not allow single value data #5470
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
Comments
would of course welcome PR / API ideas on this (and other sparse issues). |
|
looks like this is not tested, so pull-requests are welcome. this is a nice work-around actually.
|
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can create a normal DataFrame with, e.g.,
pandas.DataFrame(0, index=[1, 2, 3], columns=["A", "B", "C"])
. However, this fails with a SparseDataFrame:It looks like the code in
SparseDataFrame.__init__
is not handling the case where the data is a single value. It has a bunch of if statements to handle different kinds of data, but falls through without creatingmgr
if none of them are met.This makes it difficult to create an "empty" SparseDataFrame whose default fill value is something other than
nan
, e.g.,pandas.SparseDataFrame(0, index=[1, 2, 3], columns=["A", "B", "C"], default_fill_value=0)
. In fact, I would suggest that if a default_fill_value is provided but no data is provided, the SparseDataFrame should be filled with the fill value (notnan
), but perhaps that warrants a separate issue.The text was updated successfully, but these errors were encountered: