python 3.x - Datetime, pandas, and timezone woes ...
stackoverflow.com › questions › 54825098Feb 22, 2019 · import pandas as pd import datetime import matplotlib matplotlib.use ('agg') # noqa import matplotlib.pyplot as plt import matplotlib.dates as mdates from time import sleep lst = [] for x in range (0, 10): lst.append ( (datetime.datetime.now (datetime.timezone.utc), x)) sleep (1) df = pd.DataFrame (lst, columns= ['Timestamp', 'Pressure']) df.plot (kind='line', x='Timestamp', y='Pressure') formatter = mdates.DateFormatter ('%m/%d %T %Z', tz=df.index.tz) plt.gca ().xaxis.set_major_formatter ...