Closed
Description
With this example of plotting a tz-aware, regular timeseries:
df = pd.DataFrame(np.random.randn(100, 3), index=pd.date_range("2012", freq='H', periods=100, tz='UTC'), columns=['a', 'b', 'c'])
df.plot()
gives a warning that the user shouldn't see I think (there is nothing to do about it):
/home/joris/scipy/pandas/pandas/core/arrays/datetimes.py:1099: UserWarning: Converting
to PeriodArray/Index representation will drop timezone information.
UserWarning,
When setting a filterwarning to error, you can see the warning is coming from a to_period()
call in the matplotlib plotting backend included in pandas:
In [5]: warnings.simplefilter("error", UserWarning)
In [6]: df.plot()
---------------------------------------------------------------------------
UserWarning Traceback (most recent call last)
<ipython-input-6-848b80e64df8> in <module>
----> 1 df.plot()
~/scipy/pandas/pandas/plotting/_core.py in __call__(self, *args, **kwargs)
846 data.columns = label_name
847
--> 848 return plot_backend.plot(data, kind=kind, **kwargs)
849
850 def line(self, x=None, y=None, **kwargs):
~/scipy/pandas/pandas/plotting/_matplotlib/__init__.py in plot(data, kind, **kwargs)
59 kwargs["ax"] = getattr(ax, "left_ax", ax)
60 plot_obj = PLOT_CLASSES[kind](data, **kwargs)
---> 61 plot_obj.generate()
62 plot_obj.draw()
63 return plot_obj.result
~/scipy/pandas/pandas/plotting/_matplotlib/core.py in generate(self)
261 self._compute_plot_data()
262 self._setup_subplots()
--> 263 self._make_plot()
264 self._add_table()
265 self._make_legend()
~/scipy/pandas/pandas/plotting/_matplotlib/core.py in _make_plot(self)
1050 from pandas.plotting._matplotlib.timeseries import _maybe_convert_index
1051
-> 1052 data = _maybe_convert_index(self._get_ax(0), self.data)
1053
1054 x = data.index # dummy, not used
~/scipy/pandas/pandas/plotting/_matplotlib/timeseries.py in _maybe_convert_index(ax, data)
252
253 if isinstance(data.index, ABCDatetimeIndex):
--> 254 data = data.to_period(freq=freq)
255 elif isinstance(data.index, ABCPeriodIndex):
256 data.index = data.index.asfreq(freq=freq)
~/scipy/pandas/pandas/core/frame.py in to_period(self, freq, axis, copy)
8379 axis = self._get_axis_number(axis)
8380 if axis == 0:
-> 8381 new_data.set_axis(1, self.index.to_period(freq=freq))
8382 elif axis == 1:
8383 new_data.set_axis(0, self.columns.to_period(freq=freq))
~/scipy/pandas/pandas/core/accessor.py in f(self, *args, **kwargs)
97 def _create_delegator_method(name):
98 def f(self, *args, **kwargs):
---> 99 return self._delegate_method(name, *args, **kwargs)
100
101 f.__name__ = name
~/scipy/pandas/pandas/core/indexes/datetimelike.py in _delegate_method(self, name, *args, **kwargs)
986
987 def _delegate_method(self, name, *args, **kwargs):
--> 988 result = operator.methodcaller(name, *args, **kwargs)(self._data)
989 if name not in self._raw_methods:
990 result = Index(result, name=self.name)
~/scipy/pandas/pandas/core/arrays/datetimes.py in to_period(self, freq)
1097 "Converting to PeriodArray/Index representation "
1098 "will drop timezone information.",
-> 1099 UserWarning,
1100 )
1101
UserWarning: Converting to PeriodArray/Index representation will drop timezone information.