| Server IP : 209.209.40.120 / Your IP : 216.73.217.112 Web Server : Microsoft-IIS/10.0 System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586 User : NEWWWW$ ( 0) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Python312/Lib/site-packages/pandas/tests/scalar/timestamp/methods/ |
Upload File : |
import pytest
from pandas._libs.tslibs import Timestamp
from pandas._libs.tslibs.dtypes import NpyDatetimeUnit
class TestTimestampNormalize:
@pytest.mark.parametrize("arg", ["2013-11-30", "2013-11-30 12:00:00"])
@pytest.mark.parametrize("unit", ["ns", "us", "ms", "s"])
def test_normalize(self, tz_naive_fixture, arg, unit):
tz = tz_naive_fixture
ts = Timestamp(arg, tz=tz).as_unit(unit)
result = ts.normalize()
expected = Timestamp("2013-11-30", tz=tz)
assert result == expected
assert result._creso == getattr(NpyDatetimeUnit, f"NPY_FR_{unit}").value
def test_normalize_pre_epoch_dates(self):
# GH: 36294
result = Timestamp("1969-01-01 09:00:00").normalize()
expected = Timestamp("1969-01-01 00:00:00")
assert result == expected