From 10d17de1eed9f5b12b7eadf85c63f6dcc6d85ad5 Mon Sep 17 00:00:00 2001 From: ivan-ngchakming Date: Fri, 18 Mar 2022 09:06:54 +0000 Subject: [PATCH 1/2] test: bar plot axis conversion regr test --- pandas/tests/plotting/test_misc.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 64c736d6314e4..ed0ffff7b4f64 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -8,6 +8,7 @@ from pandas import ( DataFrame, Series, + Timestamp, ) import pandas._testing as tm from pandas.tests.plotting.common import ( @@ -549,3 +550,13 @@ def test_externally_shared_axes(self): assert not plots[0][0].xaxis.get_label().get_visible() assert plots[0][1].xaxis.get_label().get_visible() assert not plots[0][2].xaxis.get_label().get_visible() + + def test_plot_bar_axis_units_timestamp_conversion(self): + # GH 38736 + # Ensure string x-axis from the second plot will not be converted to datetime + # due to axis data from first plot + DataFrame( + [1.0], + index=[Timestamp("2022-02-22 22:22:22")], + ).plot() + Series({"A": 1.0}).plot.bar() From ce9e72cbafae186e97a8b8dc052063ebd079f159 Mon Sep 17 00:00:00 2001 From: ivan-ngchakming Date: Sat, 19 Mar 2022 14:05:08 +0800 Subject: [PATCH 2/2] test: added check plot works assertion --- pandas/tests/plotting/test_misc.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index ed0ffff7b4f64..656590cdb02be 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -555,8 +555,10 @@ def test_plot_bar_axis_units_timestamp_conversion(self): # GH 38736 # Ensure string x-axis from the second plot will not be converted to datetime # due to axis data from first plot - DataFrame( + df = DataFrame( [1.0], index=[Timestamp("2022-02-22 22:22:22")], - ).plot() - Series({"A": 1.0}).plot.bar() + ) + _check_plot_works(df.plot) + s = Series({"A": 1.0}) + _check_plot_works(s.plot.bar)