|
3 | 3 | import pandas as pd
|
4 | 4 | import pandas.util.testing as tm
|
5 | 5 | import pandas.core.indexes.period as period
|
6 |
| -from pandas import Series, period_range, DataFrame |
7 |
| - |
| 6 | +from pandas import Series, period_range, DataFrame, Period |
| 7 | +import pytest |
8 | 8 |
|
9 | 9 | def _permute(obj):
|
10 | 10 | return obj.take(np.random.permutation(len(obj)))
|
@@ -167,3 +167,23 @@ def test_truncate(self):
|
167 | 167 | pd.Period('2017-09-02')
|
168 | 168 | ])
|
169 | 169 | tm.assert_series_equal(result2, pd.Series([2], index=expected_idx2))
|
| 170 | + |
| 171 | + @pytest.mark.parametrize('input_vals', [ |
| 172 | + [Period('2016-01', freq='M'), Period('2016-02', freq='M')], |
| 173 | + [Period('2016-01-01', freq='D'), Period('2016-01-02', freq='D')], |
| 174 | + [Period('2016-01-01 00:00:00', freq='H'), |
| 175 | + Period('2016-01-01 01:00:00', freq='H')], |
| 176 | + [Period('2016-01-01 00:00:00', freq='M'), |
| 177 | + Period('2016-01-01 00:01:00', freq='M')], |
| 178 | + [Period('2016-01-01 00:00:00', freq='S'), |
| 179 | + Period('2016-01-01 00:00:01', freq='S')] |
| 180 | + ]) |
| 181 | + def test_end_time_timevalues(self, input_vals): |
| 182 | + # GH 17157 |
| 183 | + # Check that the time part of the Period is adjusted by end_time |
| 184 | + # when using the dt accessor on a Series |
| 185 | + |
| 186 | + s = Series(input_vals) |
| 187 | + result = s.dt.end_time |
| 188 | + expected = s.apply(lambda x: x.end_time) |
| 189 | + tm.assert_series_equal(result, expected) |
0 commit comments