| 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 : /Python312/Lib/site-packages/pandas/tests/indexes/datetimes/methods/ |
Upload File : |
import numpy as np
from pandas import (
Index,
Timestamp,
date_range,
)
import pandas._testing as tm
class TestDateTimeIndexToJulianDate:
def test_1700(self):
dr = date_range(start=Timestamp("1710-10-01"), periods=5, freq="D")
r1 = Index([x.to_julian_date() for x in dr])
r2 = dr.to_julian_date()
assert isinstance(r2, Index) and r2.dtype == np.float64
tm.assert_index_equal(r1, r2)
def test_2000(self):
dr = date_range(start=Timestamp("2000-02-27"), periods=5, freq="D")
r1 = Index([x.to_julian_date() for x in dr])
r2 = dr.to_julian_date()
assert isinstance(r2, Index) and r2.dtype == np.float64
tm.assert_index_equal(r1, r2)
def test_hour(self):
dr = date_range(start=Timestamp("2000-02-27"), periods=5, freq="h")
r1 = Index([x.to_julian_date() for x in dr])
r2 = dr.to_julian_date()
assert isinstance(r2, Index) and r2.dtype == np.float64
tm.assert_index_equal(r1, r2)
def test_minute(self):
dr = date_range(start=Timestamp("2000-02-27"), periods=5, freq="min")
r1 = Index([x.to_julian_date() for x in dr])
r2 = dr.to_julian_date()
assert isinstance(r2, Index) and r2.dtype == np.float64
tm.assert_index_equal(r1, r2)
def test_second(self):
dr = date_range(start=Timestamp("2000-02-27"), periods=5, freq="s")
r1 = Index([x.to_julian_date() for x in dr])
r2 = dr.to_julian_date()
assert isinstance(r2, Index) and r2.dtype == np.float64
tm.assert_index_equal(r1, r2)