Jovian
⭐️
Sign In
In [32]:
import seaborn as sns
import pandas as pd
import  numpy as np
from datetime import datetime
In [2]:
data=pd.read_csv("data.csv")
In [3]:
data.head()
Out[3]:
In [4]:
def convert_date(date):
    return datetime.strptime(date,'%m/%d/%Y  %H:%M')
In [5]:
convert_date("5/7/2003 0:00" )
Out[5]:
datetime.datetime(2003, 5, 7, 0, 0)
In [6]:
data
Out[6]:
In [7]:
start_date=input("enter the start date in mm/dd/yyyy format")
end_date=input("enter the end date in mm/dd/yyyy format")
enter the start date in mm/dd/yyyy format12/12/1998 enter the end date in mm/dd/yyyy format2/23/2019
In [34]:
total_sales=data[(data["ORDERDATE"]>start_date) & (data["ORDERDATE"]<end_date)]["SALES"].sum()
In [35]:
number_of_sales=data[(data["ORDERDATE"]>start_date) & (data["ORDERDATE"]<end_date)]["SALES"].value_counts()
In [10]:
data['SALES'].sum()
Out[10]:
10032628.85
In [36]:
sales_citywise=data[(data["ORDERDATE"]>start_date) & (data["ORDERDATE"]<end_date)]["CITY"].value_counts()
In [12]:
data
Out[12]:
In [37]:
sales_by_productline=data[(data["ORDERDATE"]>start_date) & (data["ORDERDATE"]<end_date)]["PRODUCTLINE"].value_counts()
In [13]:
avg_price=data["SALES"].mean()
In [14]:
avg_price
Out[14]:
3553.88907190932
In [38]:
q1=data[data["SALES"]<avg_price]["PRODUCTLINE"].value_counts()
In [16]:
data
Out[16]:
In [43]:
q2=data[data["SALES"]<avg_price]["PRODUCTLINE"].value_counts()
In [44]:
q3=data[data["STATUS"]=='Cancelled']["STATUS"].value_counts()
In [45]:
q4=data[data["STATUS"]=='Shipped']["STATUS"].value_counts()
In [20]:
data
Out[20]:
In [21]:
max_sale=data["SALES"].max()
In [46]:
q5=data[(data["SALES"]>avg_price) & (data["SALES"]==max_sale)]["PRODUCTLINE"]
In [47]:
min_sale=data["SALES"].min()
In [48]:
cheap= data["PRICEEACH"].min()
In [49]:
q6=data[(data["SALES"]<avg_price) & (data["SALES"]==min_sale)]["PRODUCTLINE"]
In [69]:
import smtplib
In [70]:
server=smtplib.SMTP('smtp.gmail.com',587)
In [71]:
server.ehlo()
Out[71]:
(250,
 b'smtp.gmail.com at your service, [106.208.233.164]\nSIZE 35882577\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES\nPIPELINING\nSMTPUTF8')
In [72]:
server.starttls()
Out[72]:
(220, b'2.0.0 Ready to start TLS')
In [73]:
server.ehlo
Out[73]:
<bound method SMTP.ehlo of <smtplib.SMTP object at 0x000001F9D8561128>>
In [74]:
server.login("bishnupriya.prusty17@gmail.com","bsydscnqgcgdbpwi")
Out[74]:
(235, b'2.7.0 Accepted')
In [75]:
report='''Subject : report within the time period of
{}-{}

1.Total sales amount within the period is {}
2.total number of sales within the period is {}
3.number of sales city wise within the period is {}
4.number of sales by productline within the period is {}
5.The average price of items sold is {} 
  a)No. of items sold which costed above the average price is{}
  b)No. of items sold which costed less than the average is {}
6.No. of orders that were cancelled is {} and No. of items that were shipped is {} 
7.The product which should be given focus to increase profitability is {}
8.The product which should be eliminated is {}
'''.format(start_date, end_date, total_sales, number_of_sales, sales_citywise, sales_by_productline, avg_price,q1, q2, q3, q4, q5, q6) 
In [76]:
#a=["bishnupriya.prusty17@gmail.com","gautamakash91@gmail.com","sonali.prusty17@gmail.com"]
In [78]:
email = input("enter your email address")
enter your email addresssonali.prusty17@gmail.com
In [79]:
server.sendmail("bishnupriya.prusty17@gmail.com",email, report)
Out[79]:
{}
In [80]:
import jovian
In [ ]:
jovian.commit()
[jovian] Saving notebook..
In [ ]: