Created
August 17, 2019 18:09
-
-
Save Hawzen/621ef8149171515e48028d94800f7ed2 to your computer and use it in GitHub Desktop.
A rough plotting of Shark Tank investors decisions regarding pitches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('season.txt', 'r', encoding="utf8") as f: | |
data = f.read() | |
investments = {} | |
for pitch in data.split('$'): # Split all pitches into chunks | |
lines = list(pitch.splitlines()) # Split a pitch by lines | |
if lines[0]=='': # If the first line is a blank then remove it | |
lines.pop(0) | |
pitch_number = int(lines[0]) * 10 + int(lines[1]) #The first line and the second line are the two digits of the pitch ID | |
price, percentage = (lines[3].split(',')) # The fourth line has the price and percentage presented by the pitch | |
investments[pitch_number] = [[int(price), float(percentage)]] # Add all that info to the investment dict | |
if 'none' not in pitch: # Successful pitches go here to add their investing data to the investment dict | |
for line in lines[4:]: # For lines of (price, percentage, investor) which are the last lines except the final | |
price, percentage, name = line.split(',') # Take out their values | |
investments[pitch_number].append([int(price), float(percentage), name]) # put them in a tuple inside the dict | |
#TODO: Change the function dict to list to dict to array using numpy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import Data_sorting | |
def combiner(*args): | |
"""Takes in a number of tuples of (price, percentage, investor) and combines them into one tuple""" | |
price, percentage = 0, 0 | |
for list in args: | |
for element in list: | |
price += int(element[0]) | |
percentage += float(element[1]) | |
return price, percentage | |
def investments_to_list(dict, combining=False): | |
#Declaring the list used | |
failed = [[], []] # This is for pitches that gone nowhere | |
pitch = [[], []] # This is for pitches that lead to investments | |
combined = [[], []] # This is for a combined look at the investments | |
#Declaring numpy arrays used | |
numpinvestors = np.zeros((6,2,len(dict.keys()))) # Secret trials are here | |
count = np.array([0, 0, 0, 0, 0]) | |
count = 0 | |
# | |
for list in dict.values(): # For every pitch in the dict, failed or successful | |
if len(list) > 1: # If its a successful pitch (at least another list or a price, percentage by investor) then go here | |
if combining: # When you want a list with the investments of each investor combined into one [price, percentage] | |
pitch[0].append((list[0])[0]) | |
pitch[1].append((list[0])[1]) | |
price, percentage = combiner(list[1:]) | |
combined[0].append(price) | |
combined[1].append(percentage) | |
# The proposed pitch price, percentage goes into this list | |
pitch[0].append((list[0])[0]) | |
pitch[1].append((list[0])[1]) | |
# Now we deal with price, percentage of | |
for i in list[1:]: # Bad Coder! dont ever do what I just did with all these if statements | |
# For every investor add the price, percentage to the 1st row, 1st and 2nd column, and [count] layers (3d axis) | |
if 'Othaim' in i[2]: | |
numpinvestors[0,:,count] = i[:2] | |
elif 'Zamel' in i[2]: | |
numpinvestors[1,:,count] = i[:2] | |
elif 'Taiba' in i[2]: | |
numpinvestors[2,:,count] = i[:2] | |
elif 'Qahtani' in i[2]: | |
numpinvestors[3, :, count] = i[:2] | |
elif 'Kurdi' in i[2]: | |
numpinvestors[4, :, count] = i[:2] | |
elif 'Batrjy' in i[2]: | |
numpinvestors[5, :, count] = i[:2] | |
count += 1 | |
else: | |
pass | |
failed[0].append((list[0])[0]) | |
failed[1].append((list[0])[1]) | |
return failed, pitch, combined, numpinvestors | |
failed, pitch, combined, numpinvestors = investments_to_list(Data_sorting.investments, combining=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data_sorting | |
import Functions as funcs | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Importing the Data | |
failed, pitch, combined, numpinvestors = funcs.investments_to_list(Data_sorting.investments, combining=True) | |
"""Failed -> pitch went nowhere, Pitch -> pitch lead to an accepted deal, investor -> accepted deals """ | |
# Creating the figure and the axes | |
fig, ax = plt.subplots(3) | |
# Plotting the first two axes | |
ax[0].scatter(failed[0], failed[1], c='red', edgecolors='black', label='Failed Pitches', alpha=0.5, s=200) | |
ax[1].scatter(pitch[0], pitch[1], c='blue', edgecolors='black', alpha=0.5, label='Successful Pitches', s=200) | |
ax[1].scatter(combined[0], combined[1], c='green', edgecolors='black', alpha=0.5, label='Accepted Pitches', s=200) | |
# Plotting the third axe | |
color = ['y', 'm', 'c', 'k', 'g', 's'] | |
names = ['Othaim', 'Zamel', 'Taiba', 'Qahtani', 'Kurdi', 'Batrjy'] | |
for cnt, investor in enumerate(range(5), 0): | |
ax[2].scatter(numpinvestors[cnt,0,:], numpinvestors[cnt,1,:], c=color[cnt], edgecolors='black', alpha=0.5, label=names[cnt], s=200) | |
ax[2].scatter(0, 0, c='w', edgecolors='w', s=1000) | |
# Additional Artists | |
ax[0].legend() | |
ax[1].legend() | |
ax[2].legend() | |
ax[0].set(ylim=[0, 1], xlabel='Riyal', ylabel='Percentage of Company', xlim=[-10e3, 10e5+10e3]) | |
ax[1].set(ylim=[0, 1], xlabel='Riyal', ylabel='Percentage of Company', xlim=[-10e3, 10e5+10e3]) | |
ax[2].set(ylim=[0, 1], xlabel='Riyal', ylabel='Percentage of Company', xlim=[-10e3, 10e5+10e3]) | |
# Showing | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 | |
1 | |
سهيل عبدالعزيز, شطافك في جيبك | |
300000, 0.1 | |
300000, 0.2, Othaim | |
300000, 0.2, Kurdi | |
$ | |
1 | |
2 | |
محمد بن مرشد, انحف وانت نايم | |
500000, 0.5 | |
none | |
$ | |
1 | |
3 | |
مناهل صابر, مؤسسة مناهل صابر للحلويات | |
250000, 0.15 | |
none | |
$ | |
1 | |
4 | |
اسماعيل عبدالقادر, ورشة دوت كوم | |
360000, 0.2 | |
360000, 0.4, Othaim | |
$ | |
2 | |
1 | |
رضا عمده, معمل مجوهرات | |
600000, 0.15 | |
600000, 0.22, Zamel | |
$ | |
2 | |
2 | |
اكرم الكنيزي, صناعة الالعاب الإلكترونية | |
400000, 0.3 | |
none | |
$ | |
2 | |
3 | |
تهاني طلال, مركز صيانة الجوالات | |
100000, 0.35 | |
none | |
$ | |
2 | |
4 | |
عبدالهادي الدالي, بنك المهندسين | |
1000000, 0.15 | |
none | |
$ | |
2 | |
5 | |
عبدالله السقاف, مطعم فول | |
900000, 0.2 | |
none | |
$ | |
2 | |
6 | |
ثامر الزقم, تطبيق هبه | |
50000, 0.15 | |
none | |
$ | |
3 | |
1 | |
سامي اوليه, العاب جماعيه | |
2000000, 0.2 | |
none | |
$ | |
3 | |
2 | |
طلال فطاني, عربتك | |
700000, 0.2 | |
400000, 0.2, Batrjy | |
400000, 0.2, Othaim | |
$ | |
3 | |
3 | |
خالد عطيه, استخراج السكر من التمر | |
7500000, 0.5 | |
none | |
$ | |
3 | |
4 | |
فيصل عشور, تاكو لاكو | |
200000, 0.15 | |
200000, 0.23, Batrjy | |
200000, 0.23, Othaim | |
$ | |
3 | |
5 | |
طلال عبدالله, نطبيق وقت الخدمة | |
600000, 0.07 | |
none | |
$ | |
3 | |
6 | |
هند العصيمي, ايرون أكس | |
300000, 0.1 | |
300000, 0.25, Taiba | |
$ | |
4 | |
1 | |
عبدالمجيد بامنيف, تطبيق صوتك | |
300000, 0.1 | |
100000, 0.15, Othaim | |
100000, 0.15, Kurdi | |
100000, 0.15, Taiba | |
$ | |
4 | |
2 | |
عبدالله القرشي, مطعم اكلات آسيوية | |
600000, 0.3 | |
none | |
$ | |
4 | |
3 | |
عائشة الدغيلبي, إعادة هوية السجين | |
500000, 0.51 | |
none | |
$ | |
4 | |
4 | |
احمد الحربي, تطبيق شحنه | |
400000, 0.1 | |
none | |
$ | |
4 | |
5 | |
احلام خوندنة, مصنع الاوراق المضيئة | |
1600000, 0.7 | |
none | |
$ | |
5 | |
1 | |
منصور الزهراني, تطبيق عزيز السفر | |
350000, 0.25 | |
150000, 0.245, Batrjy | |
150000, 0.245, Qahtani | |
$ | |
5 | |
2 | |
علي الخالدي, تحويل الاطعمة | |
150000, 0.15 | |
none | |
$ | |
5 | |
3 | |
فهد الحارثي, روح جروب | |
1500000, 0.49 | |
none | |
$ | |
5 | |
4 | |
مشعل العوهلي, عربية ورد | |
250000, 0.4 | |
none | |
$ | |
5 | |
5 | |
صلاح اكرامي, مركز عناية السيارات | |
540000, 0.3 | |
none | |
$ | |
6 | |
1 | |
عبدالله باشير, قهوة قطرات | |
300000, 0.16 | |
none | |
$ | |
6 | |
2 | |
سعود الفارس, تطبيق قلم | |
200000, 0.2 | |
none | |
$ | |
6 | |
3 | |
منيرة بن عيسى, حزام امان | |
300000, 0.3 | |
none | |
$ | |
6 | |
4 | |
محمد طيار, كليب اون اب | |
200000, 0.15 | |
75000, 0.1, Othaim | |
75000, 0.1, Kurdi | |
75000, 0.1, Taiba | |
75000, 0.1, Qahtani | |
$ | |
7 | |
1 | |
نواف ابارهيم, سوارة | |
150000, 0.15 | |
175000, 0.2, Othaim | |
175000, 0.2, Taiba | |
$ | |
7 | |
2 | |
محمد المشيقح, بين لينز | |
500000, 0.2 | |
none | |
$ | |
7 | |
3 | |
نجلا عبدالمجيد, دانتيلا | |
50000, 0.1 | |
none | |
$ | |
7 | |
4 | |
ضحى الجهني, فندق اطفال | |
1500000, 0.15 | |
none | |
$ | |
7 | |
5 | |
نبيل الغامدي, شاورما شاطر | |
2000000, 0.1 | |
none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment