Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TST] Parse arrow_dtype as datetime index #60097

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
import numpy as np
import pytest

from pandas._config import using_string_dtype

import pandas as pd
import pandas._testing as tm
from pandas import (
DataFrame,
DatetimeIndex,
Expand All @@ -24,10 +23,9 @@
Series,
Timestamp,
)
import pandas._testing as tm
from pandas._config import using_string_dtype
from pandas.core.indexes.datetimes import date_range
from pandas.core.tools.datetimes import start_caching_at

from pandas.io.parsers import read_csv

pytestmark = pytest.mark.filterwarnings(
Expand Down Expand Up @@ -848,6 +846,34 @@ def test_parse_dates_arrow_engine(all_parsers):
tm.assert_frame_equal(result, expected)


def test_parse_dates_arrow_dtype_as_index(all_parsers):
# GH#57930
parser = all_parsers
data = """a,b
2000-01-01 00:00:00,1
2000-01-01 00:00:01,1"""

result = parser.read_csv(
StringIO(data),
parse_dates=["a"],
index_col="a",
dtype_backend="pyarrow",
)
expected = Series(
[1, 1],
name="b",
dtype="int64[pyarrow]",
index=Index(
[
Timestamp("2000-01-01 00:00:00"),
Timestamp("2000-01-01 00:00:01"),
],
name="a",
),
).to_frame()
tm.assert_frame_equal(result, expected)


@xfail_pyarrow # object dtype index
def test_from_csv_with_mixed_offsets(all_parsers):
parser = all_parsers
Expand Down
Loading