Monthly Average Retail Prices of Essential Commodities in India from January 2012 to July 2017

You can see the data cleansing process here.

In [13]:
import pandas as pd
import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
%matplotlib inline
In [14]:
data = pd.read_pickle("retail_price_data.pkl")
In [15]:
def plot_price(series_list, title_str, xlabel_str, ylabel_str, leg_loc = "best", leg_out = False, disable_leg = False):
    fig, ax = plt.subplots()
    fig.set_size_inches(12, 6)
    data_index = series_list[0].index
    for s in series_list:
        ax.plot(data_index.to_pydatetime(), s, label = s.name, lw = 2)
    plt.grid(True)
    years = mdates.YearLocator()
    yearsFmt = mdates.DateFormatter('%Y')
    ax.xaxis.set_major_locator(years)
    ax.xaxis.set_major_formatter(yearsFmt)
    datemin = datetime.date(data_index.date.min().year, 1, 1)
    datemax = datetime.date(data_index.date.max().year + 1, 1, 1)
    ax.set_xlim(datemin, datemax)
    legend_font = {'family': 'ETBembo', 'size' : 17, 'style' : 'italic'}
    if disable_leg:
        pass
    elif leg_out:
        L = ax.legend(frameon = True, loc = 'center left', bbox_to_anchor=(1, 0.5))
        plt.setp(L.texts, **legend_font)
    else:
        L = ax.legend(frameon = True, loc = leg_loc)
        L.get_frame().set_edgecolor('w')
        plt.setp(L.texts, **legend_font)
    title_font = {'family': 'ETBembo', 'size' : 20, 'style' : 'italic'}
    plt.title(title_str, y=1.02, **title_font)
    plt.yticks(family = "mononoki", size = 13)
    plt.xticks(family = "mononoki", size = 13, rotation = 45)
    label_font = {'family': 'ETBembo', 'size' : 16, 'style' : 'normal'}
    plt.xlabel(xlabel_str, **label_font)
    plt.ylabel(ylabel_str, **label_font)
    plt.style.use("custom")
    plt.show()
In [16]:
plot_price([data["Gram"], data["Tur"], data["Urad"], data["Moong"], data["Masoor"]],
           "Retail Prices of Dals", "Year", "Price in Rs./Kg.")
In [17]:
plot_price([data["Potato"], data["Tomato"], data["Onion"]], 
           "Retail Prices of Vegetables", "Year", "Price in Rs./Kg.")
In [18]:
plot_price([data["Rice"], data["Wheat"], data["Atta (Wheat)"]], "Retail Prices of Grains", "Year", "Price in Rs./Kg.")
In [19]:
plot_price([data["Groundnut Oil"],data["Mustard Oil"], data["Palm Oil"], data["Sunflower Oil"], data["Soya Oil"]], 
           "Retail Prices of Oils", "Year", "Price in Rs./Kg.", leg_out = True)
In [20]:
plot_price([data["Sugar"], data["Gur"]], "Retail Prices of Sugar and Gur", "Year", "Price in Rs./Kg.")
In [21]:
plot_price([data["Vanaspati"]], "Retail Prices of Vanaspati", "Year", "Price in Rs./Kg.", disable_leg = True)
In [22]:
plot_price([data["Salt (Iodised)"]], "Retail Prices of Iodised Salt", "Year", "Price in Rs./Kg.", disable_leg = True)
In [23]:
plot_price([data["Tea (Loose)"]], "Retail Prices of Loose Tea", "Year", "Price in Rs./Kg.", disable_leg = True)
In [24]:
plot_price([data["Milk"]], "Retail Prices of Milk", "Year", "Price in Rs./Litre", disable_leg = True)