-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: infer_dtype with decimal/complex #37176
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
Conversation
@@ -2546,8 +2565,6 @@ def fast_multiget(dict mapping, ndarray keys, default=np.nan): | |||
# kludge, for Series | |||
return np.empty(0, dtype='f8') | |||
|
|||
keys = getattr(keys, 'values', keys) | |||
|
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.
unrelated cleanup
pandas/_libs/lib.pyx
Outdated
@@ -1414,10 +1414,12 @@ def infer_dtype(value: object, skipna: bool = True) -> str: | |||
return "time" | |||
|
|||
elif is_decimal(val): | |||
return "decimal" | |||
if all(is_decimal(x) for x in 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.
can you create is_decimal_array to have the same style
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.
i think you actually want to use the validator e.g as a raw NaN would not work here
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.
can you expand on this? do you expect something other than Decimal objects to work here?
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.
NaNs are valid as well here; but more important is that every validator has the same pattern. a is_* function e.g. is_decimal_array, which should call here.
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.
updated to use the is_* pattern.
since decimal has Decimal("nan"), i wouldnt expect to accept np.nan here
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.
since decimal has Decimal("nan"), i wouldnt expect to accept np.nan here
yeah ok, though i think we could actually accept np.nan as well and infer a decimal if that is the case (as we do this for all other dtypes). can you open an issue.
thanks |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Does this need a whatsnew?