| 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/series/methods/ |
Upload File : |
import pytest
import pandas.util._test_decorators as td
from pandas import (
Interval,
Period,
Series,
Timedelta,
Timestamp,
)
@pytest.mark.parametrize(
"values, dtype, expected_dtype",
(
([1], "int64", int),
([1], "Int64", int),
([1.0], "float64", float),
([1.0], "Float64", float),
(["abc"], "object", str),
(["abc"], "string", str),
([Interval(1, 3)], "interval", Interval),
([Period("2000-01-01", "D")], "period[D]", Period),
([Timedelta(days=1)], "timedelta64[ns]", Timedelta),
([Timestamp("2000-01-01")], "datetime64[ns]", Timestamp),
pytest.param([1], "int64[pyarrow]", int, marks=td.skip_if_no("pyarrow")),
pytest.param([1.0], "float64[pyarrow]", float, marks=td.skip_if_no("pyarrow")),
pytest.param(["abc"], "string[pyarrow]", str, marks=td.skip_if_no("pyarrow")),
),
)
def test_tolist_scalar_dtype(values, dtype, expected_dtype):
# GH49890
ser = Series(values, dtype=dtype)
result_dtype = type(ser.tolist()[0])
assert result_dtype == expected_dtype