Skip to content

Commit 06b73f5

Browse files
authored
Replace undocumented strftime usage in TimesliderChoropleth example. (#919)
In the TimesliderChoropleth Jupyter notebook example `.strftime('%s')` is used to convert datetime objects to an epoch timestamp string. This is undocumented and system dependent and can lead to unexpected behavior. So as an alternative we can convert the Pandas DateTimeIndex object to epoch timestamps and then to strings, which leads to the same result.
1 parent b6bf216 commit 06b73f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Bug Fixes
3636
- Fix disappearing layer control when using FastMarkerCluster (conengmo #866)
3737
- Host heatmap.js to circumvent adblockers (conengmo #886)
3838
- Fix permission error in Map._to_png() due to tempfile (conengmo #887)
39+
- Replace strftime use in TimesliderChoropleth example (conengmo #919)
3940

4041
0.5.0
4142
~~~~~

examples/TimeSliderChoropleth.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@
257257
"\n",
258258
"assert n_sample < n_periods\n",
259259
"\n",
260-
"dt_index = pd.date_range(\n",
261-
" '2016-1-1', periods=n_periods, freq='M'\n",
262-
").strftime('%s')\n",
260+
"datetime_index = pd.date_range('2016-1-1', periods=n_periods, freq='M')\n",
261+
"dt_index_epochs = datetime_index.astype(int) // 10**9\n",
262+
"dt_index = dt_index_epochs.astype('U10')\n",
263263
"\n",
264264
"dt_index"
265265
]

0 commit comments

Comments
 (0)