@@ -1369,31 +1369,30 @@ The default behavior remains the same, but issues a warning:
1369
1369
1370
1370
In [3]: pd.DatetimeIndex([946684800000000000], tz="US/Central")
1371
1371
/bin/ipython:1: FutureWarning:
1372
- Passing integer-dtype data and a timezone to DatetimeIndex.
1373
- Integer values will be interpreted differently in a future version
1374
- of pandas. Previously, these were viewed as datetime64[ns] values
1375
- representing the wall time *in the specified timezone*.
1376
- In the future, these will be viewed as datetime64[ns] values
1377
- representing the wall time *in UTC*. This is similar to a
1378
- nanosecond-precision UNIX epoch.
1379
- To accept the future behavior, use
1372
+ Passing integer-dtype data and a timezone to DatetimeIndex. Integer values
1373
+ will be interpreted differently in a future version of pandas. Previously,
1374
+ these were viewed as datetime64[ns] values representing the wall time
1375
+ *in the specified timezone*. In the future, these will be viewed as
1376
+ datetime64[ns] values representing the wall time *in UTC*. This is similar
1377
+ to a nanosecond-precision UNIX epoch. To accept the future behavior, use
1380
1378
1381
1379
pd.to_datetime(integer_data, utc=True).tz_convert(tz)
1382
1380
1383
1381
To keep the previous behavior, use
1384
1382
1385
- pd.to_datetime(integer_data).tz_localize(tz)
1383
+ pd.to_datetime(integer_data).tz_localize(tz)
1386
1384
1387
- #!/bin/python3
1385
+ #!/bin/python3
1388
1386
Out[3]: DatetimeIndex(['2000-01-01 00:00:00-06:00'], dtype='datetime64[ns, US/Central]', freq=None)
1389
1387
1390
- As the warning message explains, opt in to the future behavior with
1388
+ As the warning message explains, opt in to the future behavior by specifying that
1389
+ the integer values are UTC, and then converting to the final timezone:
1391
1390
1392
1391
.. ipython :: python
1393
1392
1394
1393
pd.to_datetime([946684800000000000 ], utc = True ).tz_convert(' US/Central' )
1395
1394
1396
- And the old behavior can be retained with
1395
+ The old behavior can be retained with by localizing directly to the final timezone:
1397
1396
1398
1397
.. ipython :: python
1399
1398
0 commit comments