-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Revert handling of i8values to DatetimeIndex #24708
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1910c7d
Apply diff
TomAugspurger 8c7357f
Updates
TomAugspurger 1597220
fixup
TomAugspurger 0eaefb1
more tests
TomAugspurger 1456699
astype changes
TomAugspurger efe95e4
Updates
TomAugspurger e617261
whatsnew
TomAugspurger 74d7320
filter not working?
TomAugspurger 35cd733
cleanups, fix bad filter
TomAugspurger 5411cab
reflow
TomAugspurger 2e00630
another
TomAugspurger 90afdee
maybe?
TomAugspurger 6633344
bye bye py2
TomAugspurger e36d998
remove xarray filter
TomAugspurger f60aa0c
maybe fixed
TomAugspurger 5806ca7
remove skip
TomAugspurger b78f82c
add docstring
jorisvandenbossche 4221760
Merge remote-tracking branch 'upstream/master' into revert-i8
TomAugspurger 8332c40
fixups
TomAugspurger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,8 +118,16 @@ def test_construction_with_alt_tz_localize(self, kwargs, tz_aware_fixture): | |
tz = tz_aware_fixture | ||
i = pd.date_range('20130101', periods=5, freq='H', tz=tz) | ||
kwargs = {key: attrgetter(val)(i) for key, val in kwargs.items()} | ||
result = DatetimeIndex(i.tz_localize(None).asi8, **kwargs) | ||
expected = i.tz_localize(None).tz_localize('UTC').tz_convert(tz) | ||
|
||
if str(tz) in ('UTC', 'tzutc()'): | ||
warn = None | ||
else: | ||
warn = FutureWarning | ||
|
||
with tm.assert_produces_warning(warn, check_stacklevel=False): | ||
result = DatetimeIndex(i.tz_localize(None).asi8, **kwargs) | ||
expected = DatetimeIndex(i, **kwargs) | ||
# expected = i.tz_localize(None).tz_localize('UTC').tz_convert(tz) | ||
tm.assert_index_equal(result, expected) | ||
|
||
# localize into the provided tz | ||
|
@@ -377,6 +385,18 @@ def test_range_kwargs_deprecated(self): | |
with tm.assert_produces_warning(FutureWarning): | ||
DatetimeIndex(start='1/1/2000', end='1/10/2000', freq='D') | ||
|
||
def test_integer_values_and_tz_deprecated(self): | ||
values = np.array([946684800000000000]) | ||
TomAugspurger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
with tm.assert_produces_warning(FutureWarning): | ||
result = DatetimeIndex(values, tz='US/Central') | ||
expected = pd.DatetimeIndex(['2000-01-01T00:00:00'], tz="US/Central") | ||
tm.assert_index_equal(result, expected) | ||
|
||
# but UTC is *not* deprecated. | ||
with tm.assert_produces_warning(None): | ||
result = DatetimeIndex(values, tz='UTC') | ||
expected = pd.DatetimeIndex(['2000-01-01T00:00:00'], tz="US/Central") | ||
|
||
def test_constructor_coverage(self): | ||
rng = date_range('1/1/2000', periods=10.5) | ||
exp = date_range('1/1/2000', periods=10) | ||
|
@@ -559,15 +579,22 @@ def test_constructor_timestamp_near_dst(self): | |
@pytest.mark.parametrize('box', [ | ||
np.array, partial(np.array, dtype=object), list]) | ||
@pytest.mark.parametrize('tz, dtype', [ | ||
['US/Pacific', 'datetime64[ns, US/Pacific]'], | ||
[None, 'datetime64[ns]']]) | ||
pytest.param('US/Pacific', 'datetime64[ns, US/Pacific]', | ||
marks=[pytest.mark.xfail(), | ||
pytest.mark.filterwarnings( | ||
"ignore:\\n Passing:FutureWarning")]), | ||
[None, 'datetime64[ns]'], | ||
]) | ||
def test_constructor_with_int_tz(self, klass, box, tz, dtype): | ||
# GH 20997, 20964 | ||
ts = Timestamp('2018-01-01', tz=tz) | ||
result = klass(box([ts.value]), dtype=dtype) | ||
expected = klass([ts]) | ||
assert result == expected | ||
|
||
# This is the desired future behavior | ||
@pytest.mark.xfail(reason="TBD", strict=False) | ||
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. TBD? 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. To be determined, thought I suppose we've determined that the test is the desired future behavior. |
||
@pytest.mark.filterwarnings("ignore:\\n Passing:FutureWarning") | ||
def test_construction_int_rountrip(self, tz_naive_fixture): | ||
# GH 12619 | ||
tz = tz_naive_fixture | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.