diff --git a/doc/source/release.rst b/doc/source/release.rst index e12e6c91d46d0..3df6bc167386c 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -47,7 +47,7 @@ pandas 0.13 - ``get_dummies`` works with NaN (:issue:`4446`) - Added a test for ``read_clipboard()`` and ``to_clipboard()`` (:issue:`4282`) - Added bins argument to ``value_counts`` (:issue:`3945`), also sort and - ascending, now available in Series method as well as top-level function. + ascending, now available in Series method as well as top-level function. - Text parser now treats anything that reads like inf ("inf", "Inf", "-Inf", "iNf", etc.) to infinity. (:issue:`4220`, :issue:`4219`), affecting ``read_table``, ``read_csv``, etc. @@ -74,6 +74,8 @@ pandas 0.13 - Better/cleaned up exceptions in core/common, io/excel and core/format (:issue:`4721`, :issue:`3954`), as well as cleaned up test cases in tests/test_frame, tests/test_multilevel (:issue:`4732`). + - Performance improvement of timesesies plotting with PeriodIndex and added + test to vbench (:issue:`4705` and :issue:`4722`) **API Changes** diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index 9d570d8bcbadf..1583a3c0b52d9 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -60,6 +60,7 @@ def test_plot(self): _check_plot_works(self.ts.plot, style='.', logx=True) _check_plot_works(self.ts.plot, style='.', loglog=True) _check_plot_works(self.ts[:10].plot, kind='bar') + _check_plot_works(self.iseries.plot) _check_plot_works(self.series[:5].plot, kind='bar') _check_plot_works(self.series[:5].plot, kind='line') _check_plot_works(self.series[:5].plot, kind='barh') diff --git a/pandas/tseries/converter.py b/pandas/tseries/converter.py index 54c2a4a2a3056..7c34562e64f6e 100644 --- a/pandas/tseries/converter.py +++ b/pandas/tseries/converter.py @@ -111,6 +111,8 @@ def convert(values, units, axis): if (isinstance(values, valid_types) or com.is_integer(values) or com.is_float(values)): return get_datevalue(values, axis.freq) + if isinstance(values, PeriodIndex): + return values.asfreq(axis.freq).values if isinstance(values, Index): return values.map(lambda x: get_datevalue(x, axis.freq)) if isinstance(values, (list, tuple, np.ndarray)): diff --git a/vb_suite/plotting.py b/vb_suite/plotting.py new file mode 100644 index 0000000000000..735ed78c1441e --- /dev/null +++ b/vb_suite/plotting.py @@ -0,0 +1,25 @@ +from vbench.benchmark import Benchmark +from datetime import datetime + +common_setup = """from pandas_vb_common import * + +try: + from pandas import date_range +except ImportError: + def date_range(start=None, end=None, periods=None, freq=None): + return DateRange(start, end, periods=periods, offset=freq) + +""" + +#----------------------------------------------------------------------------- +# Timeseries plotting + +setup = common_setup + """ +N = 2000 +M = 5 +df = DataFrame(np.random.randn(N,M), index=date_range('1/1/1975', periods=N)) +""" + +plot_timeseries_period = Benchmark("df.plot()", setup=setup, + name='plot_timeseries_period') + diff --git a/vb_suite/suite.py b/vb_suite/suite.py index 905c4371837cc..ca83855c2a109 100644 --- a/vb_suite/suite.py +++ b/vb_suite/suite.py @@ -17,6 +17,7 @@ 'miscellaneous', 'panel_ctor', 'parser', + 'plotting', 'reindex', 'replace', 'sparse',