|
6 | 6 |
|
7 | 7 | import numpy as np
|
8 | 8 | import pytest
|
9 |
| -import pytz |
10 | 9 |
|
11 | 10 | from pandas._libs.tslibs import (
|
12 | 11 | iNaT,
|
|
22 | 21 | INVALID_FREQ_ERR_MSG,
|
23 | 22 | IncompatibleFrequency,
|
24 | 23 | )
|
25 |
| -from pandas._libs.tslibs.timezones import ( |
26 |
| - dateutil_gettz, |
27 |
| - maybe_get_tz, |
28 |
| -) |
29 | 24 |
|
30 | 25 | import pandas as pd
|
31 | 26 | from pandas import (
|
@@ -583,70 +578,6 @@ def test_hash(self):
|
583 | 578 | # --------------------------------------------------------------
|
584 | 579 | # to_timestamp
|
585 | 580 |
|
586 |
| - @pytest.mark.parametrize("tzstr", ["Europe/Brussels", "Asia/Tokyo", "US/Pacific"]) |
587 |
| - def test_to_timestamp_tz_arg(self, tzstr): |
588 |
| - # GH#34522 tz kwarg deprecated |
589 |
| - with tm.assert_produces_warning(FutureWarning): |
590 |
| - p = Period("1/1/2005", freq="M").to_timestamp(tz=tzstr) |
591 |
| - exp = Timestamp("1/1/2005", tz="UTC").tz_convert(tzstr) |
592 |
| - exp_zone = pytz.timezone(tzstr).normalize(p) |
593 |
| - |
594 |
| - assert p == exp |
595 |
| - assert p.tz == exp_zone.tzinfo |
596 |
| - assert p.tz == exp.tz |
597 |
| - |
598 |
| - with tm.assert_produces_warning(FutureWarning): |
599 |
| - p = Period("1/1/2005", freq="3H").to_timestamp(tz=tzstr) |
600 |
| - exp = Timestamp("1/1/2005", tz="UTC").tz_convert(tzstr) |
601 |
| - exp_zone = pytz.timezone(tzstr).normalize(p) |
602 |
| - |
603 |
| - assert p == exp |
604 |
| - assert p.tz == exp_zone.tzinfo |
605 |
| - assert p.tz == exp.tz |
606 |
| - |
607 |
| - with tm.assert_produces_warning(FutureWarning): |
608 |
| - p = Period("1/1/2005", freq="A").to_timestamp(freq="A", tz=tzstr) |
609 |
| - exp = Timestamp(day=31, month=12, year=2005, tz="UTC").tz_convert(tzstr) |
610 |
| - exp_zone = pytz.timezone(tzstr).normalize(p) |
611 |
| - |
612 |
| - assert p == exp |
613 |
| - assert p.tz == exp_zone.tzinfo |
614 |
| - assert p.tz == exp.tz |
615 |
| - |
616 |
| - with tm.assert_produces_warning(FutureWarning): |
617 |
| - p = Period("1/1/2005", freq="A").to_timestamp(freq="3H", tz=tzstr) |
618 |
| - exp = Timestamp("1/1/2005", tz="UTC").tz_convert(tzstr) |
619 |
| - exp_zone = pytz.timezone(tzstr).normalize(p) |
620 |
| - |
621 |
| - assert p == exp |
622 |
| - assert p.tz == exp_zone.tzinfo |
623 |
| - assert p.tz == exp.tz |
624 |
| - |
625 |
| - @pytest.mark.parametrize( |
626 |
| - "tzstr", |
627 |
| - ["dateutil/Europe/Brussels", "dateutil/Asia/Tokyo", "dateutil/US/Pacific"], |
628 |
| - ) |
629 |
| - def test_to_timestamp_tz_arg_dateutil(self, tzstr): |
630 |
| - tz = maybe_get_tz(tzstr) |
631 |
| - with tm.assert_produces_warning(FutureWarning): |
632 |
| - p = Period("1/1/2005", freq="M").to_timestamp(tz=tz) |
633 |
| - exp = Timestamp("1/1/2005", tz="UTC").tz_convert(tzstr) |
634 |
| - assert p == exp |
635 |
| - assert p.tz == dateutil_gettz(tzstr.split("/", 1)[1]) |
636 |
| - assert p.tz == exp.tz |
637 |
| - |
638 |
| - with tm.assert_produces_warning(FutureWarning): |
639 |
| - p = Period("1/1/2005", freq="M").to_timestamp(freq="3H", tz=tz) |
640 |
| - exp = Timestamp("1/1/2005", tz="UTC").tz_convert(tzstr) |
641 |
| - assert p == exp |
642 |
| - assert p.tz == dateutil_gettz(tzstr.split("/", 1)[1]) |
643 |
| - assert p.tz == exp.tz |
644 |
| - |
645 |
| - def test_to_timestamp_tz_arg_dateutil_from_string(self): |
646 |
| - with tm.assert_produces_warning(FutureWarning): |
647 |
| - p = Period("1/1/2005", freq="M").to_timestamp(tz="dateutil/Europe/Brussels") |
648 |
| - assert p.tz == dateutil_gettz("Europe/Brussels") |
649 |
| - |
650 | 581 | def test_to_timestamp_mult(self):
|
651 | 582 | p = Period("2011-01", freq="M")
|
652 | 583 | assert p.to_timestamp(how="S") == Timestamp("2011-01-01")
|
|
0 commit comments