Skip to content

Instantly share code, notes, and snippets.

@chrisdmell
Created January 15, 2022 10:59
Show Gist options
  • Save chrisdmell/1f2582a8fa2a3f24989e3359db0f8910 to your computer and use it in GitHub Desktop.
Save chrisdmell/1f2582a8fa2a3f24989e3359db0f8910 to your computer and use it in GitHub Desktop.
def clean_seat(x):
'''
input is a string object and not a list
'''
# a = [float(sing_price) for price in x for sing_price in price.split(",")]
# a = [sing_price for price in x for sing_price in price.split(",")]
# return sum(a)/len(a)
a = [float(price) for price in x.split(",")]
return sum(a)/len(a)
def average_s1_s2_price(s1, s2):
'''
pandas series as input
for price 1 and price 2 all 4 combination covered.
'''
price_output = []
# for i in range(len(s1)):
if (s1 == 0) & (s2 == 0):
return 0
elif (s1 == 0) & (s2 !=0 ):
return s2
elif (s1 != 1) & (s2 ==0 ):
return s1
else :
return (s1+s2)/2
# return price_output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment