43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
import pandas as pd
|
|
|
|
def covertorDataFrame():
|
|
|
|
df = pd.read_csv("res/Stores.csv")
|
|
|
|
# кол-во строчек для считывания
|
|
countMainRows = 35
|
|
|
|
# получаем указанное кол-во строчек
|
|
mainDF = df.head(countMainRows)
|
|
|
|
mainDF['TextStoreArea'] = mainDF['Store_Area'].apply(
|
|
lambda x: 'Small_Area' if x <= 1100 else ('Average_Area' if 1100 < x <= 1700 else 'Big_Area'))
|
|
|
|
mainDF['TextStoreSales'] = mainDF['Store_Sales'].apply(
|
|
lambda x: 'Small_Sales' if x <= 50000 else ('Average_Sales' if 50000 < x <= 80000 else 'Big_Sales'))
|
|
|
|
mainDF['TextDailyCustomerCount'] = mainDF['Daily_Customer_Count'].apply(
|
|
lambda x: 'Small_Customer' if x <= 400 else ('Average_Customer' if 400 < x <= 900 else 'Big_Customer'))
|
|
|
|
# using dictionary to convert specific columns
|
|
convert_dict = {'Store_ID': str,
|
|
'Store_Area': str,
|
|
'Items_Available': str,
|
|
'Daily_Customer_Count': str,
|
|
'Store_Sales': str
|
|
}
|
|
|
|
newMainDF = mainDF.astype(convert_dict)
|
|
|
|
# генеральная выборка
|
|
newDfGeneral = newMainDF.iloc[0:25]
|
|
|
|
# выборка для проверки
|
|
newDfSupport = newMainDF.iloc[25:35]
|
|
|
|
return [newDfGeneral[['TextDailyCustomerCount', 'TextStoreArea', 'TextStoreSales']],
|
|
newDfSupport[['TextDailyCustomerCount', 'TextStoreArea', 'TextStoreSales']]]
|
|
|
|
# [['Store_Area', 'Store_Sales', 'Daily_Customer_Count', 'TextStoreArea']]
|
|
|
|
# [['Store_ID', 'Store_Area', 'TextStoreArea', 'Items_Available', 'Daily_Customer_Count', 'Store_Sales']] |