36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
import pandas as pd
|
|
|
|
def covertorDataFrame():
|
|
|
|
df = pd.read_csv("../../res/Stores.csv")
|
|
|
|
countMainRows = 25
|
|
|
|
newDf = df.head(countMainRows)
|
|
|
|
newDf['TextStoreArea'] = df['Store_Area'].apply(
|
|
lambda x: 'Small_Area' if x <= 1100 else ('Average_Area' if 1100 < x <= 1700 else 'Big_Area'))
|
|
|
|
newDf['TextStoreSales'] = df['Store_Sales'].apply(
|
|
lambda x: 'Small_Sales' if x <= 50000 else ('Average_Sales' if 50000 < x <= 80000 else 'Big_Sales'))
|
|
|
|
newDf['TextDailyCustomerCount'] = df['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
|
|
}
|
|
|
|
newDf = newDf.astype(convert_dict)
|
|
|
|
print(newDf[['TextStoreSales', 'TextStoreSales', 'TextStoreArea']])
|
|
|
|
return newDf[['TextDailyCustomerCount', 'TextStoreArea', 'TextStoreSales']]
|
|
|
|
# [['Store_Area', 'Store_Sales', 'Daily_Customer_Count', 'TextStoreArea']]
|
|
|
|
# [['Store_ID', 'Store_Area', 'TextStoreArea', 'Items_Available', 'Daily_Customer_Count', 'Store_Sales']] |