Skip to content

Commit

Permalink
TST: Test non-nanosecond datetimes in PyArrow Parquet dataframes (#59393
Browse files Browse the repository at this point in the history
)

* Add test_non_nanosecond_timestamps

* Fix lint errors

* Remove detailed comment; use temp path helper

* Use temp_file

* Apply suggestions from code review

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>

* Remove extra empty line

* Skip test in minimal version env

---------

Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
  • Loading branch information
EduardAkhmetshin and mroeschke authored Aug 19, 2024
1 parent eac20cc commit 3097190
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pandas/tests/io/test_parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,21 @@ def test_infer_string_large_string_type(self, tmp_path, pa):
# assert result["strings"].dtype == "string"
# FIXME: don't leave commented-out

def test_non_nanosecond_timestamps(self, temp_file):
# GH#49236
pa = pytest.importorskip("pyarrow", "11.0.0")
pq = pytest.importorskip("pyarrow.parquet")

arr = pa.array([datetime.datetime(1600, 1, 1)], type=pa.timestamp("us"))
table = pa.table([arr], names=["timestamp"])
pq.write_table(table, temp_file)
result = read_parquet(temp_file)
expected = pd.DataFrame(
data={"timestamp": [datetime.datetime(1600, 1, 1)]},
dtype="datetime64[us]",
)
tm.assert_frame_equal(result, expected)


class TestParquetFastParquet(Base):
@pytest.mark.xfail(reason="datetime_with_nat gets incorrect values")
Expand Down

0 comments on commit 3097190

Please sign in to comment.