@@ -69,10 +69,10 @@ def tearDown(self):
69
69
pass
70
70
71
71
def _check_pandas_roundtrip (self , df , expected = None , nthreads = 1 ,
72
- timestamps_to_ms = False , expected_schema = None ,
72
+ expected_schema = None ,
73
73
check_dtype = True , schema = None ,
74
74
check_index = False ):
75
- table = pa .Table .from_pandas (df , timestamps_to_ms = timestamps_to_ms ,
75
+ table = pa .Table .from_pandas (df ,
76
76
schema = schema , preserve_index = check_index )
77
77
result = table .to_pandas (nthreads = nthreads )
78
78
if expected_schema :
@@ -92,9 +92,8 @@ def _check_series_roundtrip(self, s, type_=None):
92
92
tm .assert_series_equal (s , result )
93
93
94
94
def _check_array_roundtrip (self , values , expected = None , mask = None ,
95
- timestamps_to_ms = False , type = None ):
96
- arr = pa .Array .from_pandas (values , timestamps_to_ms = timestamps_to_ms ,
97
- mask = mask , type = type )
95
+ type = None ):
96
+ arr = pa .Array .from_pandas (values , mask = mask , type = type )
98
97
result = arr .to_pandas ()
99
98
100
99
values_nulls = pd .isnull (values )
@@ -332,21 +331,6 @@ def test_fixed_size_bytes_does_not_accept_varying_lengths(self):
332
331
pa .Table .from_pandas (df , schema = schema )
333
332
334
333
def test_timestamps_notimezone_no_nulls (self ):
335
- df = pd .DataFrame ({
336
- 'datetime64' : np .array ([
337
- '2007-07-13T01:23:34.123' ,
338
- '2006-01-13T12:34:56.432' ,
339
- '2010-08-13T05:46:57.437' ],
340
- dtype = 'datetime64[ms]' )
341
- })
342
- field = pa .field ('datetime64' , pa .timestamp ('ms' ))
343
- schema = pa .schema ([field ])
344
- self ._check_pandas_roundtrip (
345
- df ,
346
- timestamps_to_ms = True ,
347
- expected_schema = schema ,
348
- )
349
-
350
334
df = pd .DataFrame ({
351
335
'datetime64' : np .array ([
352
336
'2007-07-13T01:23:34.123456789' ,
@@ -357,36 +341,24 @@ def test_timestamps_notimezone_no_nulls(self):
357
341
field = pa .field ('datetime64' , pa .timestamp ('ns' ))
358
342
schema = pa .schema ([field ])
359
343
self ._check_pandas_roundtrip (
360
- df , expected_schema = schema ,
344
+ df ,
345
+ expected_schema = schema ,
361
346
)
362
347
363
348
def test_timestamps_to_ms_explicit_schema (self ):
364
349
# ARROW-1328
365
350
df = pd .DataFrame ({'datetime' : [datetime (2017 , 1 , 1 )]})
366
351
pa_type = pa .from_numpy_dtype (df ['datetime' ].dtype )
367
352
368
- arr = pa .Array .from_pandas (df ['datetime' ], type = pa_type ,
369
- timestamps_to_ms = True )
353
+ with tm .assert_produces_warning (FutureWarning ,
354
+ check_stacklevel = False ):
355
+ arr = pa .Array .from_pandas (df ['datetime' ], type = pa_type ,
356
+ timestamps_to_ms = True )
370
357
371
358
tm .assert_almost_equal (df ['datetime' ].values .astype ('M8[ms]' ),
372
359
arr .to_pandas ())
373
360
374
361
def test_timestamps_notimezone_nulls (self ):
375
- df = pd .DataFrame ({
376
- 'datetime64' : np .array ([
377
- '2007-07-13T01:23:34.123' ,
378
- None ,
379
- '2010-08-13T05:46:57.437' ],
380
- dtype = 'datetime64[ms]' )
381
- })
382
- field = pa .field ('datetime64' , pa .timestamp ('ms' ))
383
- schema = pa .schema ([field ])
384
- self ._check_pandas_roundtrip (
385
- df ,
386
- timestamps_to_ms = True ,
387
- expected_schema = schema ,
388
- )
389
-
390
362
df = pd .DataFrame ({
391
363
'datetime64' : np .array ([
392
364
'2007-07-13T01:23:34.123456789' ,
@@ -397,7 +369,8 @@ def test_timestamps_notimezone_nulls(self):
397
369
field = pa .field ('datetime64' , pa .timestamp ('ns' ))
398
370
schema = pa .schema ([field ])
399
371
self ._check_pandas_roundtrip (
400
- df , expected_schema = schema ,
372
+ df ,
373
+ expected_schema = schema ,
401
374
)
402
375
403
376
def test_timestamps_with_timezone (self ):
@@ -410,7 +383,7 @@ def test_timestamps_with_timezone(self):
410
383
})
411
384
df ['datetime64' ] = (df ['datetime64' ].dt .tz_localize ('US/Eastern' )
412
385
.to_frame ())
413
- self ._check_pandas_roundtrip (df , timestamps_to_ms = True )
386
+ self ._check_pandas_roundtrip (df )
414
387
415
388
self ._check_series_roundtrip (df ['datetime64' ])
416
389
@@ -425,15 +398,8 @@ def test_timestamps_with_timezone(self):
425
398
})
426
399
df ['datetime64' ] = (df ['datetime64' ].dt .tz_localize ('US/Eastern' )
427
400
.to_frame ())
428
- self ._check_pandas_roundtrip (df )
429
-
430
- def test_timestamp_with_tz_to_pandas_type (self ):
431
- from pyarrow .compat import DatetimeTZDtype
432
401
433
- tz = 'America/Los_Angeles'
434
- t = pa .timestamp ('ns' , tz = tz )
435
-
436
- assert t .to_pandas_dtype () == DatetimeTZDtype ('ns' , tz = tz )
402
+ self ._check_pandas_roundtrip (df )
437
403
438
404
def test_date_infer (self ):
439
405
df = pd .DataFrame ({
0 commit comments