TST: Interchange implementation for timestamp[ns][pyarrow] (#57026) · pandas-dev/pandas@56b5979 (original) (raw)

Original file line number Diff line number Diff line change
@@ -293,6 +293,30 @@ def test_multi_chunk_pyarrow() -> None:
293 293 pd.api.interchange.from_dataframe(table, allow_copy=False)
294 294
295 295
296 +def test_timestamp_ns_pyarrow():
297 +# GH 56712
298 +pytest.importorskip("pyarrow", "11.0.0")
299 +timestamp_args = {
300 +"year": 2000,
301 +"month": 1,
302 +"day": 1,
303 +"hour": 1,
304 +"minute": 1,
305 +"second": 1,
306 + }
307 +df = pd.Series(
308 + [datetime(**timestamp_args)],
309 +dtype="timestamp[ns][pyarrow]",
310 +name="col0",
311 + ).to_frame()
312 +
313 +dfi = df.__dataframe__()
314 +result = pd.api.interchange.from_dataframe(dfi)["col0"].item()
315 +
316 +expected = pd.Timestamp(**timestamp_args)
317 +assert result == expected
318 +
319 +
296 320 @pytest.mark.parametrize("tz", ["UTC", "US/Pacific"])
297 321 def test_datetimetzdtype(tz, unit):
298 322 # GH 54239