| 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/indexes/datetimelike_/ |
Upload File : |
import numpy as np
import pytest
from pandas import (
DatetimeIndex,
NaT,
PeriodIndex,
TimedeltaIndex,
)
import pandas._testing as tm
class NATests:
def test_nat(self, index_without_na):
empty_index = index_without_na[:0]
index_with_na = index_without_na.copy(deep=True)
index_with_na._data[1] = NaT
assert empty_index._na_value is NaT
assert index_with_na._na_value is NaT
assert index_without_na._na_value is NaT
idx = index_without_na
assert idx._can_hold_na
tm.assert_numpy_array_equal(idx._isnan, np.array([False, False]))
assert idx.hasnans is False
idx = index_with_na
assert idx._can_hold_na
tm.assert_numpy_array_equal(idx._isnan, np.array([False, True]))
assert idx.hasnans is True
class TestDatetimeIndexNA(NATests):
@pytest.fixture
def index_without_na(self, tz_naive_fixture):
tz = tz_naive_fixture
return DatetimeIndex(["2011-01-01", "2011-01-02"], tz=tz)
class TestTimedeltaIndexNA(NATests):
@pytest.fixture
def index_without_na(self):
return TimedeltaIndex(["1 days", "2 days"])
class TestPeriodIndexNA(NATests):
@pytest.fixture
def index_without_na(self):
return PeriodIndex(["2011-01-01", "2011-01-02"], freq="D")