Skip to content

Commit

Permalink
TST: Make read_csv tests pyarrow 13 compatable on 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Nov 6, 2023
1 parent 8a616b9 commit 18f5a7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions pandas/tests/io/parser/common/test_common_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def test_read_csv_local(all_parsers, csv1):

fname = prefix + str(os.path.abspath(csv1))
result = parser.read_csv(fname, index_col=0, parse_dates=True)

# TODO: make unit check more specific
if parser.engine == "pyarrow":
result.index = result.index.as_unit("ns")
expected = DataFrame(
[
[0.980269, 3.685731, -0.364216805298, -1.159738],
Expand Down Expand Up @@ -177,7 +179,9 @@ def test_read_csv_low_memory_no_rows_with_index(all_parsers):
def test_read_csv_dataframe(all_parsers, csv1):
parser = all_parsers
result = parser.read_csv(csv1, index_col=0, parse_dates=True)

# TODO: make unit check more specific
if parser.engine == "pyarrow":
result.index = result.index.as_unit("ns")
expected = DataFrame(
[
[0.980269, 3.685731, -0.364216805298, -1.159738],
Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,15 @@ def test_parse_dates_custom_euro_format(all_parsers, kwargs):
)


def test_parse_tz_aware(all_parsers, request):
def test_parse_tz_aware(all_parsers):
# See gh-1693
parser = all_parsers
data = "Date,x\n2012-06-13T01:39:00Z,0.5"

result = parser.read_csv(StringIO(data), index_col=0, parse_dates=True)
# TODO: make unit check more specific
if parser.engine == "pyarrow":
result.index = result.index.as_unit("ns")
expected = DataFrame(
{"x": [0.5]}, index=Index([Timestamp("2012-06-13 01:39:00+00:00")], name="Date")
)
Expand Down Expand Up @@ -2231,6 +2234,9 @@ def test_parse_dates_arrow_engine(all_parsers):
2000-01-01 00:00:01,1"""

result = parser.read_csv(StringIO(data), parse_dates=["a"])
# TODO: make unit check more specific
if parser.engine == "pyarrow":
result["a"] = result["a"].dt.as_unit("ns")
expected = DataFrame(
{
"a": [
Expand Down

0 comments on commit 18f5a7d

Please sign in to comment.