-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Clean old timezone issues PT2 #21612
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 5 commits
7be630d
f2407f7
64bb8c4
5cb631b
1af397b
ed1209b
dde8389
2a0e57f
e304b4c
0f63b69
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 |
---|---|---|
|
@@ -1688,6 +1688,20 @@ def test_getitem_list_duplicates(self): | |
expected = df.iloc[:, 2:] | ||
assert_frame_equal(result, expected) | ||
|
||
def test_getitem_setitem_datetimeindex_tz(self): | ||
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. I think there are other tests like this, can you co-locate (IIRC in same file), maybe though in pandas/tests/indexing/.... |
||
# GH 11679 | ||
data = ['2016-06-28 08:30:00.123456789'] | ||
index = DatetimeIndex(data, dtype='datetime64[ns, America/Chicago]') | ||
df = DataFrame({'a': [10]}, index=index) | ||
result = df.loc[df.index[0]] | ||
expected = Series(10, index=['a'], name=df.index[0]) | ||
tm.assert_series_equal(result, expected) | ||
|
||
result = df.copy() | ||
result.loc[df.index[0], 'a'] = -1 | ||
expected = DataFrame(-1, index=index, columns=['a']) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_get_value(self): | ||
for idx in self.frame.index: | ||
for col in self.frame.columns: | ||
|
@@ -2248,6 +2262,16 @@ def test_setitem_datetimelike_with_inference(self): | |
index=list('ABCDEFGH')) | ||
assert_series_equal(result, expected) | ||
|
||
@pytest.mark.parametrize('idxer', ['var', ['var']]) | ||
@pytest.mark.parametrize('tz', [None, 'UTC']) | ||
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. try to use the tz fixtures if possible |
||
def test_setitem_datetimeindex_tz(self, idxer, tz): | ||
# GH 11365 | ||
idx = date_range(start='2015-07-12', periods=3, freq='H', tz=tz) | ||
expected = DataFrame(1.2, index=idx, columns=['var']) | ||
result = DataFrame(index=idx, columns=['var']) | ||
result.loc[:, idxer] = expected | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_at_time_between_time_datetimeindex(self): | ||
index = date_range("2012-01-01", "2012-01-05", freq='30min') | ||
df = DataFrame(randn(len(index), 5), index=index) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,6 +292,15 @@ def test_construct_over_dst(self): | |
freq='H', tz='US/Pacific') | ||
tm.assert_index_equal(result, expected) | ||
|
||
def test_construct_with_different_start_end_string_format(self): | ||
# GH 12064 | ||
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. not sure this is actually testing what is in the issue, as there were provided tz's there. 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. tz aren't provided in these examples via the keyword arg. The issue was that |
||
result = date_range('2013-01-01 00:00:00+09:00', | ||
'2013/01/01 02:00:00+09:00', freq='H') | ||
expected = DatetimeIndex([Timestamp('2013-01-01 00:00:00+09:00'), | ||
Timestamp('2013-01-01 01:00:00+09:00'), | ||
Timestamp('2013-01-01 02:00:00+09:00')]) | ||
tm.assert_index_equal(result, expected) | ||
|
||
|
||
class TestGenRangeGeneration(object): | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,6 +450,14 @@ def test_offset_deprecated(self): | |
with tm.assert_produces_warning(FutureWarning): | ||
idx.offset = BDay() | ||
|
||
def test_ts_datetimeindex_compare_mismatched_tz(self, comparison_fixture): | ||
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. we have similar tests, can you co-locate |
||
# GH 12601 | ||
comparison = comparison_fixture | ||
idx = date_range('2016-01-01 12:00', periods=10, | ||
freq='H', tz='Asia/Tokyo') | ||
with pytest.raises(TypeError): | ||
comparison(idx, pd.Timestamp('2016-01-01 08:00')) | ||
|
||
|
||
class TestBusinessDatetimeIndex(object): | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1185,3 +1185,11 @@ def test_constructor_range_dtype(self, dtype): | |
expected = Series([0, 1, 2, 3, 4], dtype=dtype or 'int64') | ||
result = Series(range(5), dtype=dtype) | ||
tm.assert_series_equal(result, expected) | ||
|
||
def test_constructor_tz_aware_and_tz_naive_data(self): | ||
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. call this tz_mixed |
||
# GH 13051 | ||
dt_list = [Timestamp('2016-05-01 02:03:37'), | ||
Timestamp('2016-04-30 19:03:37-0700', tz='US/Pacific')] | ||
result = Series(dt_list) | ||
expected = Series(dt_list, dtype=object) | ||
tm.assert_series_equal(result, expected) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,3 +249,12 @@ def test_replace_mixed_types_with_string(self): | |
result = s.replace([2, '4'], np.nan) | ||
expected = pd.Series([1, np.nan, 3, np.nan, 4, 5]) | ||
tm.assert_series_equal(expected, result) | ||
|
||
@pytest.mark.parametrize('to_replace', [pd.NaT, [np.nan, pd.NaT]]) | ||
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. I think we have a fixture for nulls |
||
def test_replace_with_tz_aware_data(self, to_replace): | ||
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. can you tests with tz-naive as well, maybe just have a combined test (as we likely have one for naive) |
||
# GH 11792 | ||
ts = pd.Timestamp('2015/01/01', tz='UTC') | ||
s = pd.Series([pd.NaT, pd.Timestamp('2015/01/01', tz='UTC')]) | ||
result = s.replace(to_replace, pd.Timestamp.min) | ||
expected = pd.Series([pd.Timestamp.min, ts], dtype=object) | ||
tm.assert_series_equal(expected, result) |
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.
make this more like this
which is much more flexible for non-operators