Таблица дополняется :)

This commit is contained in:
ElEgEv 2023-10-11 21:14:43 +04:00
parent ec32341418
commit f7c9a0b58b
2 changed files with 9 additions and 8 deletions

View File

@ -3,16 +3,12 @@ import pandas
# создаём усовершенствованную таблицу
def addData(df: pandas.DataFrame):
# узнаём средние значения для всех столбцов
mean_store_sales = df['Store_Sales'].mean()
mean_daily_customer_count = df['Daily_Customer_Count'].mean()
mean_items_available = df['Items_Available'].mean()
mean_store_area = df['Store_Area'].mean()
additionForTable = int(len(df) / 10)
# ищем 10% от кол-ва строк (-1 из-за строки заголовков)
additionForTable = int(len(df) / 10) - 1
# добавили 10% значений
for i in range(additionForTable):
df.loc[len(df.index)] = [mean_store_area, mean_items_available, mean_daily_customer_count, mean_store_sales]
df.loc[len(df.index)] = [df['Store_ID'].max().round(2) + 1, df['Store_Area'].mean().round(2), df['Items_Available'].mean().round(2),
df['Daily_Customer_Count'].mean().round(2), df['Store_Sales'].mean().round(2)]
return df

View File

@ -5,6 +5,7 @@ from LabWork01.AnalysSales import analysSalesDataFrame
from LabWork01.AnalysSalesCustomers import analysSalesCustomersDataFrame
from LabWork01.DataFrameAnalys import analysItemsDataFrame
from LabWork01.FuncLoad import createDataFrame
from LabWork01.LabWork3.AddData import addData
app = Flask(__name__)
@ -19,6 +20,10 @@ countNull = listShops.isnull().sum()
@app.route("/")
def home():
listShops = addData(createDataFrame())
print(listShops)
return render_template('main_page.html', context=[], tableAnalys=[], titles=[''], listTypes=listTypes, countNull=countNull, firstRow=1, secondRow=4, firstColumn=1, secondColumn=4)
@app.route("/showDiapason", methods=['GET','POST'])