Sales Trend Analysis With Pandas
Tags: timeseries, python, datascience, analytics
Published: 2022-02-02 18:28:18

## Assessment
You have just been employed as Data analyst in one of the fast growing product manufacturing and distribution companies and your first welcoming task by MD is to create a report for an upcoming board meeting. You are to go through and analyze the sales data from 2015-2017 in order to generate the requested report.

The report should capture the following;
1. Revenue by region
2. Revenue by sales Rep
3. Revenue by products
4. Sales trend
5. Yearly changes in revenue
**Highlight the following on the report:**
* Top 3 products
* The most productive sales Rep in the respective years. From your analysis, give 3 recommendations you think would help the company increase revenue in the following year.

**Data Source:**<br>
https://docs.google.com/spreadsheets/d/1SWCOO70Yv7PPvmlLyLQj1gCilg1XsSl0/edit?usp=sharing&ouid=102731908679789782364&rtpof=true&sd=true

**Github code:** https://github.com/anochima/Sales-Data-Analysis


```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
```


```python
# Setup our visuals to use seaborn by default
plt.style.use('seaborn')
plt.rcParams["figure.figsize"] = (11, 4)
```


```python
# Import our data using pandas
df = pd.read_excel('MODULE 2-Assessment working data.xlsx')

# Convert the sales excel file into .csv (Comma Separated Value)
# This is only done because because I feel more comfortable working with Csv files to xlsx files
df = df.to_csv('sales-data.csv', index=False)

# Read the sales data
df = pd.read_csv('sales-data.csv')
```


```python
df.head()
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Date</th>
      <th>SalesRep</th>
      <th>Region</th>
      <th>Product</th>
      <th>Color</th>
      <th>Units</th>
      <th>Revenue</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>2015-11-06</td>
      <td>Julie</td>
      <td>East</td>
      <td>Sunshine</td>
      <td>Blue</td>
      <td>4</td>
      <td>78.8</td>
    </tr>
    <tr>
      <th>1</th>
      <td>2015-11-07</td>
      <td>Adam</td>
      <td>West</td>
      <td>Bellen</td>
      <td>Clear</td>
      <td>4</td>
      <td>123.0</td>
    </tr>
    <tr>
      <th>2</th>
      <td>2015-11-07</td>
      <td>Julie</td>
      <td>East</td>
      <td>Aspen</td>
      <td>Clear</td>
      <td>1</td>
      <td>26.0</td>
    </tr>
    <tr>
      <th>3</th>
      <td>2015-11-07</td>
      <td>Nabil</td>
      <td>South</td>
      <td>Quad</td>
      <td>Clear</td>
      <td>2</td>
      <td>69.0</td>
    </tr>
    <tr>
      <th>4</th>
      <td>2015-11-07</td>
      <td>Julie</td>
      <td>South</td>
      <td>Aspen</td>
      <td>Blue</td>
      <td>2</td>
      <td>51.0</td>
    </tr>
  </tbody>
</table>
</div>




```python
df.describe(include=['object','float','int'])
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Date</th>
      <th>SalesRep</th>
      <th>Region</th>
      <th>Product</th>
      <th>Color</th>
      <th>Units</th>
      <th>Revenue</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>count</th>
      <td>9971</td>
      <td>9971</td>
      <td>9971</td>
      <td>9971</td>
      <td>9971</td>
      <td>9971.000000</td>
      <td>9971.000000</td>
    </tr>
    <tr>
      <th>unique</th>
      <td>717</td>
      <td>6</td>
      <td>3</td>
      <td>7</td>
      <td>5</td>
      <td>NaN</td>
      <td>NaN</td>
    </tr>
    <tr>
      <th>top</th>
      <td>2016-09-11</td>
      <td>Julie</td>
      <td>West</td>
      <td>Bellen</td>
      <td>Red</td>
      <td>NaN</td>
      <td>NaN</td>
    </tr>
    <tr>
      <th>freq</th>
      <td>77</td>
      <td>2233</td>
      <td>4417</td>
      <td>1948</td>
      <td>3020</td>
      <td>NaN</td>
      <td>NaN</td>
    </tr>
    <tr>
      <th>mean</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>3.388828</td>
      <td>91.181513</td>
    </tr>
    <tr>
      <th>std</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>4.320759</td>
      <td>120.894473</td>
    </tr>
    <tr>
      <th>min</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>1.000000</td>
      <td>21.000000</td>
    </tr>
    <tr>
      <th>25%</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>2.000000</td>
      <td>42.900000</td>
    </tr>
    <tr>
      <th>50%</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>2.000000</td>
      <td>60.000000</td>
    </tr>
    <tr>
      <th>75%</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>3.000000</td>
      <td>76.500000</td>
    </tr>
    <tr>
      <th>max</th>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>NaN</td>
      <td>25.000000</td>
      <td>1901.750000</td>
    </tr>
  </tbody>
</table>
</div>



### Some useful Insights

There was a total of `9,971` sales entries between 2015-2017 out of which the following descriptions were made:

**Units:**
* The minimum number of units sold between 2015-2017 was `1` 
* The maximum number of units sold between 2015-2017 was `25`
* The average number of units sold between 2015-2017 was aproximately `3`

**Revenue**
* The least revenue generated between 2015-2017 was `21` 
* The most revenue between 2015-2017 was approximately `1902`

**---Others---**
* We had `6` unique Sales Representatives between 2015-2017 
* We covered `3` Regions between 2015-2017
* `5` unique colors


```python
# At what amount did we sell most?

df['Revenue'].value_counts().hist(bins=50);
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2rkyilk8o46044gk3nzc.png)
    


Here most items were sold between 21 - 70 respectively


```python
df['Units'].hist(bins=50);
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s8ovuwmzf3ony2n8pmkj.png)
    



```python
# What's the total revenue generated between 2015-2017?

round(df['Revenue'].sum())
```




    909171




```python
df.info()
```

    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 9971 entries, 0 to 9970
    Data columns (total 7 columns):
     #   Column    Non-Null Count  Dtype  
    ---  ------    --------------  -----  
     0   Date      9971 non-null   object 
     1   SalesRep  9971 non-null   object 
     2   Region    9971 non-null   object 
     3   Product   9971 non-null   object 
     4   Color     9971 non-null   object 
     5   Units     9971 non-null   int64  
     6   Revenue   9971 non-null   float64
    dtypes: float64(1), int64(1), object(5)
    memory usage: 545.4+ KB



```python
# Check if we have any missing entry
df.isna().sum()
```




    Date        0
    SalesRep    0
    Region      0
    Product     0
    Color       0
    Units       0
    Revenue     0
    dtype: int64



No entry is missing

## Revenue by region


```python
region_revenue = pd.DataFrame(df.groupby(by=['Region'])['Revenue'].sum())
region_revenue.sort_values(ascending=False, by='Revenue')
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Region</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>West</th>
      <td>408037.58</td>
    </tr>
    <tr>
      <th>South</th>
      <td>263256.50</td>
    </tr>
    <tr>
      <th>East</th>
      <td>237876.79</td>
    </tr>
  </tbody>
</table>
</div>



Visualize region revenue impact


```python
region_revenue.plot(kind='bar', ylabel='Revenue', title='Region revenue impact');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pldo9d776qgu73e6fl1.png)
    


It's very clear that the `West Region` generated the most revenue

## Revenue by sales Rep


```python
sales_rep_revenue = df.groupby(by=['SalesRep'])['Revenue'].sum()
sales_rep_revenue = pd.DataFrame(sales_rep_revenue).sort_values(ascending=True, by='Revenue')
sales_rep_revenue
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>SalesRep</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Nicole</th>
      <td>92026.68</td>
    </tr>
    <tr>
      <th>Adam</th>
      <td>102715.60</td>
    </tr>
    <tr>
      <th>Jessica</th>
      <td>145496.28</td>
    </tr>
    <tr>
      <th>Nabil</th>
      <td>158904.48</td>
    </tr>
    <tr>
      <th>Julie</th>
      <td>204450.05</td>
    </tr>
    <tr>
      <th>Mike</th>
      <td>205577.78</td>
    </tr>
  </tbody>
</table>
</div>



Visualize salesRep revenue impact


```python
sales_rep_revenue.plot(kind='bar', ylabel='Revenue', title='SalesRep revenue impact');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/71dc43j4bu3zlprdffgd.png)
    



```python
print('Mike Slightly beat Julie in revenue generation by ' + str(round(((sales_rep_revenue.loc['Mike'] - sales_rep_revenue.loc['Julie']) / sales_rep_revenue.loc['Julie']) * 100, 2))+'%')
```

    Mike Slightly beat Julie in revenue generation by Revenue    0.55
    dtype: float64%


## Revenue by products


```python
product_revenue = df[['Units', 'Revenue','Product']].groupby('Product').sum().sort_values(ascending=False,by='Units')
product_revenue
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Units</th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Product</th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Bellen</th>
      <td>6579</td>
      <td>168175.05</td>
    </tr>
    <tr>
      <th>Quad</th>
      <td>6223</td>
      <td>194032.15</td>
    </tr>
    <tr>
      <th>Sunbell</th>
      <td>4500</td>
      <td>114283.09</td>
    </tr>
    <tr>
      <th>Carlota</th>
      <td>4371</td>
      <td>101272.05</td>
    </tr>
    <tr>
      <th>Aspen</th>
      <td>4242</td>
      <td>96382.80</td>
    </tr>
    <tr>
      <th>Sunshine</th>
      <td>4229</td>
      <td>85983.80</td>
    </tr>
    <tr>
      <th>Doublers</th>
      <td>3646</td>
      <td>149041.93</td>
    </tr>
  </tbody>
</table>
</div>



 Visualize of Products revenue impact


```python
product_revenue.groupby(by=['Product'])['Revenue'].sum().sort_values(ascending=True).plot(
                                                                                          kind='bar',ylabel='Revenue',title='Product Revenue');
```



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzhauwhlizw6ybiuyw3k.png)
    


# Sales trend


```python
# Convert the date column to a datetime object
df['Date'] = pd.to_datetime(df['Date'])
df['Year'] = df['Date'].dt.year
df['Month'] = df['Date'].dt.month
df['Day']  = df['Date'].dt.day
# df = df.drop('Date',axis=1)
```

## Plot Yearly Sales Chart/Trend


```python
years = [unique for unique in df.Year.unique()]
years
```




    [2015, 2016, 2017]




```python
def plot_trend(years:list, df):
    for year in years:
        new_df = df[df['Year'] == year]
        new_df.groupby('Date')['Revenue'].sum().plot(linewidth=1.2, 
                                             ylabel='Revenue', 
                                             xlabel='Date', 
                                             title='Sales Trend');
```


```python
import matplotlib.patches as patches

year1 = patches.Patch(color='blue', label='2015')
year2 = patches.Patch(color='green', label='2016')
year3 = patches.Patch(color='red', label='2017')
plot_trend(years, df)
plt.legend(handles=[year1,year2,year3], loc=2);
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xn7b2odfhf67cyzk1y1.png)
    


**The trend plot looks symmetrical for the months of October in 2017 and 2018 respectively. <br> This shows that most sales are made within the month of October. what could have influenced this?**


```python
ax = df[['Month', 'Units', 'Revenue']].groupby('Month').sum().plot(
                                                                 title='Monthly Sales Trend', 
                                                                 ylabel='Revenue',
                                                                 );
ax.vlines(10,1,300000, linestyles='dashed')
ax.annotate('Oct',(10,0));
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tvhmowh9m0fdn3t1wyvb.png)
    


**How many times was entry made in each month?**



```python
df['Month'].value_counts().sort_values().plot(kind='bar', xlabel='Month', ylabel='Number of Entries', title='Monthly Entries');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cm6hlmuh37ua6smr22sp.png)
    



```python
products = pd.DataFrame(df[['Units','Revenue','Product','Month', 'Region']].groupby('Month')['Product'].value_counts())
products
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th></th>
      <th>Product</th>
    </tr>
    <tr>
      <th>Month</th>
      <th>Product</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th rowspan="5" valign="top">1</th>
      <th>Bellen</th>
      <td>52</td>
    </tr>
    <tr>
      <th>Quad</th>
      <td>46</td>
    </tr>
    <tr>
      <th>Sunbell</th>
      <td>34</td>
    </tr>
    <tr>
      <th>Aspen</th>
      <td>33</td>
    </tr>
    <tr>
      <th>Sunshine</th>
      <td>33</td>
    </tr>
    <tr>
      <th>...</th>
      <th>...</th>
      <td>...</td>
    </tr>
    <tr>
      <th rowspan="5" valign="top">12</th>
      <th>Sunbell</th>
      <td>43</td>
    </tr>
    <tr>
      <th>Aspen</th>
      <td>41</td>
    </tr>
    <tr>
      <th>Sunshine</th>
      <td>36</td>
    </tr>
    <tr>
      <th>Carlota</th>
      <td>35</td>
    </tr>
    <tr>
      <th>Doublers</th>
      <td>32</td>
    </tr>
  </tbody>
</table>
<p>84 rows × 1 columns</p>
</div>




```python
products['No_of_products'] = products['Product']
products.drop('Product', inplace=True, axis=1)
products = products.reset_index()
```


```python
products
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Month</th>
      <th>Product</th>
      <th>No_of_products</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>1</td>
      <td>Bellen</td>
      <td>52</td>
    </tr>
    <tr>
      <th>1</th>
      <td>1</td>
      <td>Quad</td>
      <td>46</td>
    </tr>
    <tr>
      <th>2</th>
      <td>1</td>
      <td>Sunbell</td>
      <td>34</td>
    </tr>
    <tr>
      <th>3</th>
      <td>1</td>
      <td>Aspen</td>
      <td>33</td>
    </tr>
    <tr>
      <th>4</th>
      <td>1</td>
      <td>Sunshine</td>
      <td>33</td>
    </tr>
    <tr>
      <th>...</th>
      <td>...</td>
      <td>...</td>
      <td>...</td>
    </tr>
    <tr>
      <th>79</th>
      <td>12</td>
      <td>Sunbell</td>
      <td>43</td>
    </tr>
    <tr>
      <th>80</th>
      <td>12</td>
      <td>Aspen</td>
      <td>41</td>
    </tr>
    <tr>
      <th>81</th>
      <td>12</td>
      <td>Sunshine</td>
      <td>36</td>
    </tr>
    <tr>
      <th>82</th>
      <td>12</td>
      <td>Carlota</td>
      <td>35</td>
    </tr>
    <tr>
      <th>83</th>
      <td>12</td>
      <td>Doublers</td>
      <td>32</td>
    </tr>
  </tbody>
</table>
<p>84 rows × 3 columns</p>
</div>




```python
products = products.pivot_table(values=['No_of_products'], index=['Month'], columns=['Product'], aggfunc= np.sum)
products
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead tr th {
        text-align: left;
    }

    .dataframe thead tr:last-of-type th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr>
      <th></th>
      <th colspan="7" halign="left">No_of_products</th>
    </tr>
    <tr>
      <th>Product</th>
      <th>Aspen</th>
      <th>Bellen</th>
      <th>Carlota</th>
      <th>Doublers</th>
      <th>Quad</th>
      <th>Sunbell</th>
      <th>Sunshine</th>
    </tr>
    <tr>
      <th>Month</th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>33</td>
      <td>52</td>
      <td>30</td>
      <td>29</td>
      <td>46</td>
      <td>34</td>
      <td>33</td>
    </tr>
    <tr>
      <th>2</th>
      <td>26</td>
      <td>45</td>
      <td>29</td>
      <td>25</td>
      <td>45</td>
      <td>35</td>
      <td>26</td>
    </tr>
    <tr>
      <th>3</th>
      <td>49</td>
      <td>55</td>
      <td>46</td>
      <td>34</td>
      <td>77</td>
      <td>35</td>
      <td>39</td>
    </tr>
    <tr>
      <th>4</th>
      <td>31</td>
      <td>37</td>
      <td>35</td>
      <td>27</td>
      <td>50</td>
      <td>43</td>
      <td>25</td>
    </tr>
    <tr>
      <th>5</th>
      <td>33</td>
      <td>52</td>
      <td>36</td>
      <td>30</td>
      <td>51</td>
      <td>37</td>
      <td>31</td>
    </tr>
    <tr>
      <th>6</th>
      <td>37</td>
      <td>53</td>
      <td>23</td>
      <td>21</td>
      <td>52</td>
      <td>30</td>
      <td>36</td>
    </tr>
    <tr>
      <th>7</th>
      <td>38</td>
      <td>60</td>
      <td>37</td>
      <td>25</td>
      <td>55</td>
      <td>46</td>
      <td>42</td>
    </tr>
    <tr>
      <th>8</th>
      <td>34</td>
      <td>54</td>
      <td>26</td>
      <td>35</td>
      <td>51</td>
      <td>35</td>
      <td>35</td>
    </tr>
    <tr>
      <th>9</th>
      <td>380</td>
      <td>596</td>
      <td>399</td>
      <td>311</td>
      <td>560</td>
      <td>397</td>
      <td>404</td>
    </tr>
    <tr>
      <th>10</th>
      <td>476</td>
      <td>735</td>
      <td>439</td>
      <td>333</td>
      <td>697</td>
      <td>491</td>
      <td>460</td>
    </tr>
    <tr>
      <th>11</th>
      <td>119</td>
      <td>154</td>
      <td>118</td>
      <td>77</td>
      <td>142</td>
      <td>108</td>
      <td>103</td>
    </tr>
    <tr>
      <th>12</th>
      <td>41</td>
      <td>55</td>
      <td>35</td>
      <td>32</td>
      <td>64</td>
      <td>43</td>
      <td>36</td>
    </tr>
  </tbody>
</table>
</div>




```python
products.plot(ylabel='No of Products sold', title='Monthly product sales');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eakmxaoj71jx83r8d3rq.png)
    


It's clear now that we sell more `Bellen` during october and that and HEAVY sales kick off between `September and late November`

## Region Monthly Revenue


```python
region_sales = pd.DataFrame(df[['Units','Revenue','Product','Month', 'Region']]).groupby(['Month','Region'])['Revenue'].sum()
region_sales = pd.DataFrame(region_sales)
region_sales
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th></th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Month</th>
      <th>Region</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th rowspan="3" valign="top">1</th>
      <th>East</th>
      <td>5012.34</td>
    </tr>
    <tr>
      <th>South</th>
      <td>7551.55</td>
    </tr>
    <tr>
      <th>West</th>
      <td>8550.33</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">2</th>
      <th>East</th>
      <td>6428.75</td>
    </tr>
    <tr>
      <th>South</th>
      <td>5540.10</td>
    </tr>
    <tr>
      <th>West</th>
      <td>10864.87</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">3</th>
      <th>East</th>
      <td>6082.75</td>
    </tr>
    <tr>
      <th>South</th>
      <td>8863.80</td>
    </tr>
    <tr>
      <th>West</th>
      <td>14087.99</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">4</th>
      <th>East</th>
      <td>6420.63</td>
    </tr>
    <tr>
      <th>South</th>
      <td>7647.28</td>
    </tr>
    <tr>
      <th>West</th>
      <td>8865.57</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">5</th>
      <th>East</th>
      <td>8782.68</td>
    </tr>
    <tr>
      <th>South</th>
      <td>5651.30</td>
    </tr>
    <tr>
      <th>West</th>
      <td>10962.00</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">6</th>
      <th>East</th>
      <td>6442.85</td>
    </tr>
    <tr>
      <th>South</th>
      <td>3954.90</td>
    </tr>
    <tr>
      <th>West</th>
      <td>9020.65</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">7</th>
      <th>East</th>
      <td>7180.45</td>
    </tr>
    <tr>
      <th>South</th>
      <td>10155.59</td>
    </tr>
    <tr>
      <th>West</th>
      <td>10150.25</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">8</th>
      <th>East</th>
      <td>6031.55</td>
    </tr>
    <tr>
      <th>South</th>
      <td>7767.60</td>
    </tr>
    <tr>
      <th>West</th>
      <td>11567.37</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">9</th>
      <th>East</th>
      <td>70532.44</td>
    </tr>
    <tr>
      <th>South</th>
      <td>83228.39</td>
    </tr>
    <tr>
      <th>West</th>
      <td>127160.06</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">10</th>
      <th>East</th>
      <td>87858.60</td>
    </tr>
    <tr>
      <th>South</th>
      <td>92034.70</td>
    </tr>
    <tr>
      <th>West</th>
      <td>151780.43</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">11</th>
      <th>East</th>
      <td>19478.10</td>
    </tr>
    <tr>
      <th>South</th>
      <td>24048.59</td>
    </tr>
    <tr>
      <th>West</th>
      <td>33196.52</td>
    </tr>
    <tr>
      <th rowspan="3" valign="top">12</th>
      <th>East</th>
      <td>7625.65</td>
    </tr>
    <tr>
      <th>South</th>
      <td>6812.70</td>
    </tr>
    <tr>
      <th>West</th>
      <td>11831.54</td>
    </tr>
  </tbody>
</table>
</div>




```python
region_sales = region_sales.reset_index()
region_sales = region_sales.pivot_table(values=['Revenue'], index=['Month'], columns=['Region'], aggfunc= np.sum)
region_sales
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead tr th {
        text-align: left;
    }

    .dataframe thead tr:last-of-type th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr>
      <th></th>
      <th colspan="3" halign="left">Revenue</th>
    </tr>
    <tr>
      <th>Region</th>
      <th>East</th>
      <th>South</th>
      <th>West</th>
    </tr>
    <tr>
      <th>Month</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>1</th>
      <td>5012.34</td>
      <td>7551.55</td>
      <td>8550.33</td>
    </tr>
    <tr>
      <th>2</th>
      <td>6428.75</td>
      <td>5540.10</td>
      <td>10864.87</td>
    </tr>
    <tr>
      <th>3</th>
      <td>6082.75</td>
      <td>8863.80</td>
      <td>14087.99</td>
    </tr>
    <tr>
      <th>4</th>
      <td>6420.63</td>
      <td>7647.28</td>
      <td>8865.57</td>
    </tr>
    <tr>
      <th>5</th>
      <td>8782.68</td>
      <td>5651.30</td>
      <td>10962.00</td>
    </tr>
    <tr>
      <th>6</th>
      <td>6442.85</td>
      <td>3954.90</td>
      <td>9020.65</td>
    </tr>
    <tr>
      <th>7</th>
      <td>7180.45</td>
      <td>10155.59</td>
      <td>10150.25</td>
    </tr>
    <tr>
      <th>8</th>
      <td>6031.55</td>
      <td>7767.60</td>
      <td>11567.37</td>
    </tr>
    <tr>
      <th>9</th>
      <td>70532.44</td>
      <td>83228.39</td>
      <td>127160.06</td>
    </tr>
    <tr>
      <th>10</th>
      <td>87858.60</td>
      <td>92034.70</td>
      <td>151780.43</td>
    </tr>
    <tr>
      <th>11</th>
      <td>19478.10</td>
      <td>24048.59</td>
      <td>33196.52</td>
    </tr>
    <tr>
      <th>12</th>
      <td>7625.65</td>
      <td>6812.70</td>
      <td>11831.54</td>
    </tr>
  </tbody>
</table>
</div>




```python
region_sales.plot(kind='bar', ylabel='Revenue', title='Region Monthly Revenue');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iy3puxcxnfvib3jxgkqc.png)
    


## Yearly changes in revenue


```python
changes = pd.DataFrame(df.groupby([df.Date.dt.year])['Revenue'].sum())
changes
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Date</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>2015</th>
      <td>24883.84</td>
    </tr>
    <tr>
      <th>2016</th>
      <td>444701.72</td>
    </tr>
    <tr>
      <th>2017</th>
      <td>439585.31</td>
    </tr>
  </tbody>
</table>
</div>




```python
changes.sort_values('Date').plot(kind='bar');
```


    

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqlg5um8gqzqsualnk1f.png)
    


## Top 3 products


```python
product_revenue
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Units</th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Product</th>
      <th></th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>Bellen</th>
      <td>6579</td>
      <td>168175.05</td>
    </tr>
    <tr>
      <th>Quad</th>
      <td>6223</td>
      <td>194032.15</td>
    </tr>
    <tr>
      <th>Sunbell</th>
      <td>4500</td>
      <td>114283.09</td>
    </tr>
    <tr>
      <th>Carlota</th>
      <td>4371</td>
      <td>101272.05</td>
    </tr>
    <tr>
      <th>Aspen</th>
      <td>4242</td>
      <td>96382.80</td>
    </tr>
    <tr>
      <th>Sunshine</th>
      <td>4229</td>
      <td>85983.80</td>
    </tr>
    <tr>
      <th>Doublers</th>
      <td>3646</td>
      <td>149041.93</td>
    </tr>
  </tbody>
</table>
</div>



Our top 3 products are `Bellen, Quad and Sunbell`

## The most productive sales Rep in the respective years. From your analysis, give 3 recommendations you think would help the company increase revenue in the following year.


```python
salesReps = df[['SalesRep','Year','Revenue','Units']]
salesReps = pd.DataFrame(salesReps.groupby(['Year','SalesRep'])['Revenue'].sum())
salesReps.sort_values(by=['Year','Revenue'], ascending=False)
```




<div>
<style scoped>
    .dataframe tbody tr th:only-of-type {
        vertical-align: middle;
    }

    .dataframe tbody tr th {
        vertical-align: top;
    }

    .dataframe thead th {
        text-align: right;
    }
</style>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th></th>
      <th>Revenue</th>
    </tr>
    <tr>
      <th>Year</th>
      <th>SalesRep</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th rowspan="6" valign="top">2017</th>
      <th>Julie</th>
      <td>99727.32</td>
    </tr>
    <tr>
      <th>Mike</th>
      <td>96062.19</td>
    </tr>
    <tr>
      <th>Nabil</th>
      <td>81079.23</td>
    </tr>
    <tr>
      <th>Jessica</th>
      <td>69479.74</td>
    </tr>
    <tr>
      <th>Adam</th>
      <td>49712.19</td>
    </tr>
    <tr>
      <th>Nicole</th>
      <td>43524.64</td>
    </tr>
    <tr>
      <th rowspan="6" valign="top">2016</th>
      <th>Mike</th>
      <td>104590.64</td>
    </tr>
    <tr>
      <th>Julie</th>
      <td>98895.58</td>
    </tr>
    <tr>
      <th>Nabil</th>
      <td>74576.22</td>
    </tr>
    <tr>
      <th>Jessica</th>
      <td>71469.42</td>
    </tr>
    <tr>
      <th>Adam</th>
      <td>49184.21</td>
    </tr>
    <tr>
      <th>Nicole</th>
      <td>45985.65</td>
    </tr>
    <tr>
      <th rowspan="6" valign="top">2015</th>
      <th>Julie</th>
      <td>5827.15</td>
    </tr>
    <tr>
      <th>Mike</th>
      <td>4924.95</td>
    </tr>
    <tr>
      <th>Jessica</th>
      <td>4547.12</td>
    </tr>
    <tr>
      <th>Adam</th>
      <td>3819.20</td>
    </tr>
    <tr>
      <th>Nabil</th>
      <td>3249.03</td>
    </tr>
    <tr>
      <th>Nicole</th>
      <td>2516.39</td>
    </tr>
  </tbody>
</table>
</div>



Julie Stands out in sales revenue yearly except in 2016

## Conclusion/Recommendation:
1. The best months for sales are September, October and November. The company should look into creating jingles during these periods to further maximize profit.
2. Focus the ad targeted audience on `East and South Regions`
3. Finally Bellen and Quad sell most during these periods consider getting more of them.