-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: assign doesnt cast SparseDataFrame to DataFrame #19178
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
Changes from 6 commits
6a10fa8
686ef8e
d874c7f
ac6213a
3042568
d900e11
a17a593
925186d
559434a
16a272d
e35bc17
2374bc6
a81796a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
is_scalar, is_dtype_equal) | ||
from pandas.core.dtypes.cast import ( | ||
maybe_convert_platform, maybe_promote, | ||
astype_nansafe, find_common_type) | ||
astype_nansafe, find_common_type, infer_dtype_from) | ||
from pandas.core.dtypes.missing import isna, notna, na_value_for_dtype | ||
|
||
import pandas._libs.sparse as splib | ||
|
@@ -195,7 +195,7 @@ def __new__(cls, data, sparse_index=None, index=None, kind='integer', | |
data = np.nan | ||
if not is_scalar(data): | ||
raise Exception("must only pass scalars with an index ") | ||
values = np.empty(len(index), dtype='float64') | ||
values = np.empty(len(index), dtype=infer_dtype_from(data)[0]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that's a good point. Since infer_dtype_from just checks is_scalar again. |
||
values.fill(data) | ||
data = values | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify what "passed in" refers to here? Is it specifically
.assign
? Or any method setting / updating the sparse array?