Skip to content
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

Interval dtype fix #25338

Merged
merged 36 commits into from
Feb 20, 2019
Merged
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6185319
Merge pull request #1 from pandas-dev/master
zangell44 Feb 15, 2019
1c4decd
interval constructor logic modified and error handling for is_dtype u…
zangell44 Feb 15, 2019
d52c631
formatting updates for error msg
zangell44 Feb 15, 2019
c1b7d7f
committing latest upstream master changes to branch
zangell44 Feb 17, 2019
953823e
subtype check logic implemented for Interval dtype
zangell44 Feb 17, 2019
8edbbd8
tests added to ensure pd.api.types.IntervalDtype.is_dtype(IntervalA)…
zangell44 Feb 17, 2019
8e54308
tests added to ensure * pd.api.types.IntervalDtype(IntervalA) throws …
zangell44 Feb 17, 2019
eec5013
test added to ensure pd.api.types.IntervalDtype.construct_from_string…
zangell44 Feb 17, 2019
708a740
PEP8 style issues resolved
zangell44 Feb 17, 2019
9ae2afc
more PEP8 style issues resolved
zangell44 Feb 17, 2019
0837c85
subtype checking consolidated into for loop
zangell44 Feb 17, 2019
c0818b6
logic change to include issubtype must result in True
zangell44 Feb 17, 2019
dedba89
logic change for checking datetime and timedelta dtypes
zangell44 Feb 17, 2019
6914a7b
extra blank line removed
zangell44 Feb 17, 2019
e9c18e9
Merge remote-tracking branch 'upstream/master' into interval-dtype-fix
zangell44 Feb 17, 2019
c53d69c
reset to original logic on working branch, only tests written remain …
zangell44 Feb 17, 2019
f2d2390
logic for string constructor and error message content updated
zangell44 Feb 18, 2019
08ea833
construction error for IntervalA parameter moved to proper test
zangell44 Feb 18, 2019
1a5fc1b
IntervalDtype construct_from_string tests updated to separate a bad d…
zangell44 Feb 18, 2019
f2a3bdb
TypeError added to is_dtype exceptions, reflecting changes in the con…
zangell44 Feb 18, 2019
0011a80
formatting fixes and test update
zangell44 Feb 19, 2019
aa581fa
formatting update
zangell44 Feb 19, 2019
54bcf76
construct from string formatting fixes
zangell44 Feb 19, 2019
36f8571
interval[foo] construct from string error moved to proper test category
zangell44 Feb 19, 2019
6e6fe23
IntervalA construct from string error moved to proper test category
zangell44 Feb 19, 2019
5547b5f
IntervalDtype construct from string test error message handling updat…
zangell44 Feb 19, 2019
aedc7cc
re-ordering of logic in construct from string method for cleaner code
zangell44 Feb 19, 2019
2deba07
message string altered to work with regex matching
zangell44 Feb 19, 2019
c107ccd
IntervalA test re-added to construct from string testing
zangell44 Feb 19, 2019
989942e
error message formatting fix for PEP8
zangell44 Feb 19, 2019
d28a0fd
test added for comparing series with strings containing Interval keyword
zangell44 Feb 19, 2019
e72bfb9
regression fix documented in whats new for v0.24.2
zangell44 Feb 19, 2019
dfe6e99
typo fix in construct_from_string error message
zangell44 Feb 19, 2019
f08915f
typo fix in construct_from_string error message
zangell44 Feb 19, 2019
f1fabdf
whatsnew note adjusted for clarity and style
zangell44 Feb 20, 2019
1ed7f8c
formatting update for test_compare_series_interval_keyword
zangell44 Feb 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,11 +893,15 @@ def __new__(cls, subtype=None):
m = cls._match.search(subtype)
if m is not None:
subtype = m.group('subtype')

try:
subtype = pandas_dtype(subtype)
except TypeError:
raise TypeError("could not construct IntervalDtype")
else:
# if no match found, a bad datatype was passed
msg = ('category, object, and string subtypes are not '
'supported for IntervalDtype')
raise TypeError(msg)
try:
subtype = pandas_dtype(subtype)
jschendel marked this conversation as resolved.
Show resolved Hide resolved
except TypeError:
raise TypeError("could not construct IntervalDtype")

if is_categorical_dtype(subtype) or is_string_dtype(subtype):
# GH 19016
Expand Down Expand Up @@ -978,7 +982,7 @@ def is_dtype(cls, dtype):
return True
else:
return False
except ValueError:
except (ValueError, TypeError):
return False
else:
return False
Expand Down