year wise trend in pandas code example

Example 1: y =mx+c trend analysis in for a column of dataframe

import matplotlib.pyplot as pltimport matplotlib.dates as mdatesfig, ax = plt.subplots()ax.grid(True)year = mdates.YearLocator(month=1)month = mdates.MonthLocator(interval=3)year_format = mdates.DateFormatter('%Y')month_format = mdates.DateFormatter('%m')ax.xaxis.set_minor_locator(month)ax.xaxis.grid(True, which = 'minor')ax.xaxis.set_major_locator(year)ax.xaxis.set_major_formatter(year_format)plt.plot(data_set.index, data_set['#Passengers'], c='blue')plt.plot(decomposition.trend.index, decomposition.trend, c='red')

Example 2: trends in yearly data python

>>> selected = fcdata.loc[('16/12/2004 20:16:00' < fcdata.index) & (fcdata.index < '16/12/2004 20:25:00'),'Feed rate']
>>> selected.plot()
>>> plt.show()