| 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/period/methods/ |
Upload File : |
from pandas import (
Index,
NaT,
Period,
PeriodIndex,
)
import pandas._testing as tm
class TestFillNA:
def test_fillna_period(self):
# GH#11343
idx = PeriodIndex(["2011-01-01 09:00", NaT, "2011-01-01 11:00"], freq="h")
exp = PeriodIndex(
["2011-01-01 09:00", "2011-01-01 10:00", "2011-01-01 11:00"], freq="h"
)
result = idx.fillna(Period("2011-01-01 10:00", freq="h"))
tm.assert_index_equal(result, exp)
exp = Index(
[
Period("2011-01-01 09:00", freq="h"),
"x",
Period("2011-01-01 11:00", freq="h"),
],
dtype=object,
)
result = idx.fillna("x")
tm.assert_index_equal(result, exp)
exp = Index(
[
Period("2011-01-01 09:00", freq="h"),
Period("2011-01-01", freq="D"),
Period("2011-01-01 11:00", freq="h"),
],
dtype=object,
)
result = idx.fillna(Period("2011-01-01", freq="D"))
tm.assert_index_equal(result, exp)