Question: import pandas as pd import numpy as np # Load the data file _ path = ' C: / Users / ASUS / Desktop /
import pandas as pd
import numpy as np
# Load the data
filepath C:UsersASUSDesktopPART mugspreferenceparametersfull.csv
data pdreadcsvfilepath
# Define the product attributes for the proposed candidate
candidate
'price':
'timeinsulated':
'capacity':
'cleanability': 'Easy',
'containment': 'Leak Resistant', # This corresponds to pCnLk
'brand': C
# Define the cost structure
coststructure
'timeinsulated': : : :
'capacity': : : :
'cleanability': Difficult: 'Fair': 'Easy':
'containment': Slosh Resistant': 'Spill Resistant': 'Leak Resistant':
# Calculate the cost of the proposed candidate
candidatecost coststructuretimeinsulated'candidatetimeinsulated'
coststructurecapacitycandidatecapacity
coststructurecleanabilitycandidatecleanability
coststructurecontainmentcandidatecontainment
# Define competitors
competitor
'price':
'timeinsulated':
'capacity':
'cleanability': 'Easy',
'containment': 'Leak Resistant', # This corresponds to pCnLk
'brand': A
competitor
'price':
'timeinsulated':
'capacity':
'cleanability': 'Fair',
'containment': 'Spill Resistant', # This corresponds to pCnSp
'brand': B
# Define utility calculation function
def calculateutilityrow product:
utility
# Check if columns exist before accessing them
pricekey fpPrproductprice
if pricekey in row:
utility rowpricekey row.getIPr
timekey f'pInproducttimeinsulated"
if timekey in row:
utility rowtimekey row.getIin
capacitykey fpCpproductcapacity
if capacitykey in row:
utility rowcapacitykey row.getICp
cleanabilitykey fpClproductcleanability
if cleanabilitykey in row:
utility rowcleanabilitykey row.getICl
containmentkey productcontainmentreplace
containmentkey fpCncontainmentkey # Ensure it matches the column name
if containmentkey in row:
utility rowcontainmentkey row.getIcn
brandkey fpBrproductbrand
if brandkey in row:
utility rowbrandkey row.getIBr
return utility
# Calculate utilities
datautilitycandidate' data.applycalculateutility, productcandidate, axis
datautilitycompetitor data.applycalculateutility, productcompetitor axis
datautilitycompetitor data.applycalculateutility, productcompetitor axis
# Calculate logitadjusted probabilities
dataexputilitycandidate' npexpdatautilitycandidate'
dataexputilitycompetitor npexpdatautilitycompetitor
dataexputilitycompetitor npexpdatautilitycompetitor
dataprobcandidate' dataexputilitycandidate'
dataexputilitycandidate' dataexputilitycompetitor dataexputilitycompetitor
# Calculate the average market share
marketsharecandidate dataprobcandidate'mean
# Calculate margin and expected profit per person
pricecandidate candidateprice
margincandidate pricecandidate candidatecost
expectedprofitperperson marketsharecandidate margincandidate
# Output the results
printfMarket Share of Candidate: marketsharecandidate
printfMargin of Candidate: margincandidate
printfExpected Profit per Person: expectedprofitperperson
# Check if expected profit per person is between and
if expectedprofitperperson :
printThe expected profit per person is between and
else:
printThe expected profit per person is not between and
Please check the code and calculation. I need the expected profit per person is to be
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
