Skip to content

Commit e1a4144

Browse files
PERF: improve perf of float-based timeseries plotting (#15073)
1 parent 42cdb34 commit e1a4144

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

asv_bench/benchmarks/plotting.py

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def setup(self):
2020
def time_plot_regular(self):
2121
self.df.plot()
2222

23+
def time_plot_regular_compat(self):
24+
self.df.plot(x_compat=True)
25+
2326

2427
class Misc(object):
2528
goal_time = 0.6

doc/source/whatsnew/v0.20.0.txt

+4
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,14 @@ Performance Improvements
281281

282282
- Improved performance of ``pd.wide_to_long()`` (:issue:`14779`)
283283
- Increased performance of ``pd.factorize()`` by releasing the GIL with ``object`` dtype when inferred as strings (:issue:`14859`)
284+
- Improved performance of timeseries plotting with an irregular DatetimeIndex
285+
(or with ``compat_x=True``) (:issue:`15073`).
286+
284287

285288
- When reading buffer object in ``read_sas()`` method without specified format, filepath string is inferred rather than buffer object.
286289

287290

291+
288292
.. _whatsnew_0200.bug_fixes:
289293

290294
Bug Fixes

pandas/tseries/converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def try_parse(values):
212212
try:
213213
values = tools.to_datetime(values)
214214
if isinstance(values, Index):
215-
values = values.map(_dt_to_float_ordinal)
215+
values = _dt_to_float_ordinal(values)
216216
else:
217217
values = [_dt_to_float_ordinal(x) for x in values]
218218
except Exception:

pandas/tseries/tests/test_converter.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import nose
44

55
import numpy as np
6-
from pandas import Timestamp, Period, Index
6+
from pandas import Timestamp, Period
77
from pandas.compat import u
88
import pandas.util.testing as tm
99
from pandas.tseries.offsets import Second, Milli, Micro
@@ -104,8 +104,8 @@ def test_dateindex_conversion(self):
104104
for freq in ('B', 'L', 'S'):
105105
dateindex = tm.makeDateIndex(k=10, freq=freq)
106106
rs = self.dtc.convert(dateindex, None, None)
107-
xp = Index(converter.dates.date2num(dateindex._mpl_repr()))
108-
tm.assert_index_equal(rs, xp, decimals)
107+
xp = converter.dates.date2num(dateindex._mpl_repr())
108+
tm.assert_almost_equal(rs, xp, decimals)
109109

110110
def test_resolution(self):
111111
def _assert_less(ts1, ts2):

0 commit comments

Comments
 (0)