-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add the decimal.Decimal type to infer_dtypes (#15690) #16426
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
@@ -462,6 +463,11 @@ def test_floats(self): | |||
result = lib.infer_dtype(arr) | |||
assert result == 'floating' | |||
|
|||
def test_decimals(self): | |||
arr = np.array([Decimal(1), Decimal(2), Decimal(3)]) |
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 add a comment with a link to the github issue? (#15690)
arr = np.array([Decimal(1), Decimal(2), Decimal(3)]) | ||
result = lib.infer_dtype(arr) | ||
assert result == 'decimal' | ||
|
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.
Sorry, could you add a test with a mix of Decimal and non-decimal (like floats) and make sure that the return is mixed
? Or search through and see if we have a test that already covers this. Other than that, this looks great.
What I am wondering is what are potential consequences of this change. As there are quite some places in the codebase where we wheck if the inferred type is 'mixed', which could lead to potential changes in behaviour for objects with Decimals with this change. |
https://travis-ci.org/pandas-dev/pandas/jobs/234948322#L1392 failed one of the vector resizing tests ( |
@jorisvandenbossche are there places where we explicitly check @margaret I'm not able to reproduce that. I'll restart that worker. |
According to my pycharm search, there are 13 occurrences of 'mixed' (usage as a string constant) |
Codecov Report
@@ Coverage Diff @@
## master #16426 +/- ##
==========================================
- Coverage 90.42% 90.42% -0.01%
==========================================
Files 161 161
Lines 51023 51023
==========================================
- Hits 46138 46137 -1
- Misses 4885 4886 +1
Continue to review full report at Codecov.
|
doc/source/whatsnew/v0.21.0.txt
Outdated
@@ -34,6 +34,7 @@ Other Enhancements | |||
- ``Series.to_dict()`` and ``DataFrame.to_dict()`` now support an ``into`` keyword which allows you to specify the ``collections.Mapping`` subclass that you would like returned. The default is ``dict``, which is backwards compatible. (:issue:`16122`) | |||
- ``RangeIndex.append`` now returns a ``RangeIndex`` object when possible (:issue:`16212`) | |||
- :func:`to_pickle` has gained a protocol parameter (:issue:`16252`). By default, this parameter is set to `HIGHEST_PROTOCOL <https://docs.python.org/3/library/pickle.html#data-stream-format>`__ | |||
- ``lib.infer_dtype`` now infers decimals. (:issue: `15690`) |
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.
:func:`api.types.infer_dtype`
@@ -308,7 +308,6 @@ def infer_dtype(object value): | |||
'categorical' | |||
|
|||
""" |
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.
pls update the doc-string & add an example
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.
If the suite passes this is prob ok. The times when we infer are:
|
One further thought: would we like to call this |
i think decimal is just fine ; don't need to get more complicated |
lgtm. ping on green. |
thanks! |
git diff upstream/master --name-only -- '*.py' | flake8 --diff