@@ -1352,6 +1352,53 @@ the object's ``freq`` attribute (:issue:`21939`, :issue:`23878`).
1352
1352
dti + pd.Index([1 * dti.freq, 2 * dti.freq])
1353
1353
1354
1354
1355
+ .. _whatsnew_0240.deprecations.integer_tz :
1356
+
1357
+ Passing Integer data and a timezone to DatetimeIndex
1358
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1359
+
1360
+ The behavior of :class: `DatetimeIndex ` when passed integer data and
1361
+ a timezone is changing in a future version of pandas. Previously, these
1362
+ were interpreted as wall times in the desired timezone. In the future,
1363
+ these will be interpreted as wall times in UTC, which are then converted
1364
+ to the desired timezone (:issue: `24559 `).
1365
+
1366
+ The default behavior remains the same, but issues a warning:
1367
+
1368
+ .. code-block :: ipython
1369
+
1370
+ In [3]: pd.DatetimeIndex([946684800000000000], tz="US/Central")
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
1380
+
1381
+ pd.to_datetime(integer_data, utc=True).tz_convert(tz)
1382
+
1383
+ To keep the previous behavior, use
1384
+
1385
+ pd.to_datetime(integer_data).tz_localize(tz)
1386
+
1387
+ #!/bin/python3
1388
+ Out[3]: DatetimeIndex(['2000-01-01 00:00:00-06:00'], dtype='datetime64[ns, US/Central]', freq=None)
1389
+
1390
+ As the warning message explains, opt in to the future behavior with
1391
+
1392
+ .. ipython :: python
1393
+
1394
+ pd.to_datetime([946684800000000000 ], utc = True ).tz_convert(' US/Central' )
1395
+
1396
+ And the old behavior can be retained with
1397
+
1398
+ .. ipython :: python
1399
+
1400
+ pd.to_datetime([946684800000000000 ]).tz_localize(' US/Central' )
1401
+
1355
1402
.. _whatsnew_0240.deprecations.tz_aware_array :
1356
1403
1357
1404
Converting Timezone-Aware Series and Index to NumPy Arrays
0 commit comments