Commit 48572f1c by logesh.n

completed

parent 0723f1a9
import smtplib import smtplib
import ssl import ssl
from readxl import df1
# importing from readxl
from readxl import avg, maximum, minimum, final_time
port = 465 # For SSL port = 465 # For SSL
smtp_server = "smtp.gmail.com" smtp_server = "smtp.gmail.com"
sender_email = "logesh.n@knowledgelens.com" # Enter your address sender_email = "logesh.n@knowledgelens.com" # Enter your address
receiver_email = ["rakeshpvofficial@gmail.com", "rakeshpvuokl@gmail.com"] # Enter receiver address receiver_email = ["rakeshpvofficial@gmail.com", "rakeshpvuokl@gmail.com", "logeshnandhakumar12@gmail.com"]
print("heloo") # Enter receiver address
print(df1)
print(type(df1))
df2 = str(df1)
print("df2", df2)
print(type(df2))
password = input("Type your password and press enter: ") password = input("Type your password and press enter: ")
message = df2 message1 = avg + maximum + minimum
message2 = final_time
message3 = str(final_time)
context = ssl.create_default_context() context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server: with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(sender_email, password) server.login(sender_email, password)
for i in range(len(receiver_email)): for i in range(len(receiver_email)):
server.sendmail(sender_email, receiver_email[i], message) server.sendmail(sender_email, receiver_email[i], message1)
# importing pandas to read the xlsx file # importing pandas to read the xlsx file
# df1 stores avg of all columns except timestamp, df2 stores max of all columns # df1 stores avg of all columns except timestamp, df2 stores max of all columns, df3 stores min of all columns
# Pandas dataframe.idxmax() method returns the index of the first occurrence of maximum over the requested axis. # Pandas dataframe.idxmax() method returns the index of the first occurrence of maximum over the requested axis.
import pandas as pd import pandas as pd
...@@ -8,23 +8,24 @@ df = pd.read_excel('D:/sources/task3.xlsx') ...@@ -8,23 +8,24 @@ df = pd.read_excel('D:/sources/task3.xlsx')
# rounding of the columns to two decimal points and getting the average of each of the columns # rounding of the columns to two decimal points and getting the average of each of the columns
df1 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].mean(), 2) df1 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].mean(), 2)
print("The average of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df1) avg = str(df1)
# rounding of the columns to two decimal points and getting the max of each of the columns # rounding of the columns to two decimal points and getting the max of each of the columns
df2 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].max(), 2) df2 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].max(), 2)
print("\nThe Maximum of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df2) maximum = str(df2)
# rounding of the columns to two decimal points and getting the min of each of the columns # rounding of the columns to two decimal points and getting the min of each of the columns
df3 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].min(), 2) df3 = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].min(), 2)
print("\nThe Minimum of kWh, kVAh, kW, kVA, current as respectively >>\n\n", df3) minimum = str(df3)
dff = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].idxmax(), 0) # finding the timestamp of max value of each column
dfff = df["current"].idxmax() df_time = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].idxmax(), 0)
print(dff) max_time = df["Timestamp"][df_time]
# col = "current" timestamps_max = str(max_time)
# max_x = df.loc[df[col].idxmax()]
# print("DS")
# print(max_x)
new = df["Timestamp"][dff] # finding the timestamp of max value of each column
print(new) df_time = round(df[["kWh", "kVAh", "kW", "kVA", "current"]].idxmin(), 0)
\ No newline at end of file min_time = df["Timestamp"][df_time]
timestamps_min = str(min_time)
final_time = timestamps_max + timestamps_min
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment