# -*- coding: utf-8 -*-
"""
Created on Mon May 15 13:22:34 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['Дата'] <= '2022-12-01')]
#print(dates)
total_production_cost = array[:,5]
total_liters_milk=array[:,6]
#average = sum(total_profit)/len(total_profit)

df['production_cost'] = array[:,5] / array[:,6]
#print(total_production_cost)
mount=array[:,0]

xpoints = mount
ypoints = df['production_cost']
plt.plot(xpoints, ypoints)

#print(df['production_cost'])


average_production_cost=sum(total_production_cost)/sum(total_liters_milk)
print("Average of profit for every years: ", round(average_production_cost,2))
 


df2 = pd.DataFrame({"col2": [round(average_production_cost,2)]})
#print (df2)
bad_botton = [0.30]
bad_range = ([0.20])
#well_botton = np.array([0])
well_range = [0.12]
#excelent_botton = np.array([11])
excelent_range = [0.30]
df = pd.DataFrame({'bad_botton' : bad_botton, 'well_range': well_range, 
                   'excelent_range' : excelent_range  })
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()