# -*- coding: utf-8 -*-
"""
Created on Sat May 13 16:33:39 2023

@author: stan
"""

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

data = pd.read_excel(r'D:\Proekt Elena\data_for_python1.xlsx') 

df = pd.DataFrame(data)
#print(df)
array = df.values
#dates=df[(df['Дата']>datetime.date(2019,1,1)) & (df['Дата']<datetime.date(2019,12,1))] 
dates=df[(df['Дата'] >= '2019-01-01') & (df['Дата'] <= '2019-12-01')]
#print(dates)
total_profit = array[:,4]
total_liters_milk=array[:,6]
#average = sum(total_profit)/len(total_profit)
average_profit=sum(total_profit)/sum(total_liters_milk)
print("Average of profit for every years: ", round(average_profit,2))

array1=dates.values
total_profit_2019 = array1[:,4]
total_liters_milk_2019=array1[:,6]
average_profit_2019=sum(total_profit_2019)/sum(total_liters_milk_2019)
print("Average of profit for year 2019: ", round(average_profit_2019,2))
#df2 = round(average_profit_2019,2)
#df2 = pd.DataFrame({"col2": [0.19]})
#df2 = pd.DataFrame({"col2": [0.19]})
df2 = pd.DataFrame({"col2": [round(average_profit_2019,2)]})
#df2=[round(average_profit_2019,2)]
#df = pd.DataFrame({[round(average_profit_2019,2)]})
#print(type(df2));
bad_botton = [-0.23]
bad_range = ([0.23])
#well_botton = np.array([0])
well_range = [0.11]
#excelent_botton = np.array([11])
excelent_range = [0.16]
index =['Печалба/литър']
df = pd.DataFrame({'bad_botton' : bad_botton, 'well_range': well_range, 
                   'excelent_range' : excelent_range  }, index=index)
ax = df.plot.bar(stacked=True)
#ax2 = ax.twinx()
ax.plot(ax.get_xticks(),
   #df[['col1', 'col2']].values,
   df2[['col2']].values,
   linestyle='-',
   marker='o', linewidth=2.0)

plt.show()