<jupyter_start><jupyter_text>Questions:1) What, on average, are the cities with the largest percentage of excellent cars (in good shape while on sale), can we attribute this to any specific city conditions?2) Is there a specific reason some cylinder type engine cars should have a larger amount of specific drive types?3) How are the qualities of the cars being sold in the three main cities of the Greater Vancouver area, what conditions can be the reason for these discrepancies?<jupyter_code>eData = {}

for area in (df["location"].unique()):
    percentage = ((df[df["location"]==area]["condition"].where(df["condition"] == " excellent").count()/
                df[df["location"]==area]["condition"].count()))
    count = df[df["location"]==area]["condition"].count()
    if percentage not in [0.0,1.0] and count > 500:
        eData[area] = percentage

#this is a pretty simple graph, we are checking the percentage of cars that have excellent conditions in the top cities
# with the most count 

dict(sorted(eData.items(), key=lambda item: item[1],reverse=False))


plt.show()

f = plt.figure()
f.set_figwidth(30)
f.set_figheight(30)

plt.yticks(fontsize=30)
plt.bar(range(len(eData)), list(eData.values()), align='center')
plt.xticks(range(len(eData)), list(eData.keys()),fontsize=15)
plt.ylabel("% of cars that are of excellent condition",fontsize=40)
plt.xlabel("Cities",fontsize=40)

plt.title("Cities vs Excellent Condition",fontsize=40)

plt.show()

dArray = []
for drive in df["drive"].unique():
    dData={}
    for cylinder in (df["cylinders"].unique()):
        percentage = ((df[df["cylinders"]==cylinder]["drive"].where(df["drive"]==drive).count()))
        dData[cylinder] = percentage 
    dArray.append(dData)
    
    

#here we are checking which type of car is more common for which engine type



dict(sorted(dArray[0].items(), key=lambda item: item[1],reverse=False))



plt.show()

f = plt.figure()
f.set_figwidth(15)
f.set_figheight(15)

X = np.arange(len(dArray[0]))


plt.yticks(fontsize=15)
plt.bar(X+0.1, list(dArray[0].values()), align='center',width=0.1, color='green')
plt.bar(X, list(dArray[2].values()), align='center', width=0.1,color='red')
plt.bar(X-0.1, list(dArray[1].values()), align='center', width=0.1,color='blue')
plt.xticks(range(len(dArray[0])), list(dArray[0].keys()),fontsize=30)
plt.ylabel("Count of specfic Drive type",fontsize=20)
plt.xlabel("Number of cylinders in engine",fontsize=20)


plt.title("Drive type vs Number of Cylinders",fontsize=40)

ar = [dArray[0].values()],[dArray[1].values()],[dArray[2].values()]

plt.legend(['Rear wheel drive','Front wheel drive','Four wheel drive'])

plt.show()<jupyter_output><empty_output><jupyter_text>It is pretty clear from the results that front wheel drive and four wheel drive are the most popular. And this is expected, most populations around the world have similar statistics. The interesting part is why are 6 cylinders favored for four wheel drive while four cylinders are favored for front wheel drive. A more accurate question would be why are there much less front wheel drive 6 cylinder cars, this is because four wheel drive are amazingly similar in both cylinder types (4 and 6). On average four wheel drive cars are much cheaper, at the same time, a smaller number of cylinders are also cheaper. This can easily explain why we see front wheel drive and four cylinder in a very large coorelation. This though, has nothing to do with the engine size or capabilites as the different types of drive do not have any influence on this. Therefore, the most reasonable answer to my original research question is that people pair up these two variables for monetary reasons.<jupyter_code>van = []
burn = []
sur = []

vanLabels = []
burnLabels = []
surLabels = []


condition = (df["condition"].unique())

for x in df["condition"].unique():
    percentage = ((df[df["location"]=="vancouver"]["condition"].where(df["condition"] == x).count())/(df[df["location"]=="vancouver"]["condition"].count()))
    if percentage > 0.01:
        van.append(percentage)
        vanLabels.append(x)

for x in df["condition"].unique():
    percentage = (df[df["location"]=="burnaby"]["condition"].where(df["condition"] == x).count())/(df[df["location"]=="burnaby"]["condition"].count())
    if percentage > 0.01:
        burn.append(percentage)
        burnLabels.append(x)
    
for x in df["condition"].unique():
    percentage = (df[df["location"]=="surrey"]["condition"].where(df["condition"] == x).count())/(df[df["location"]=="surrey"]["condition"].count())
    if percentage > 0.01:
        sur.append(percentage)
        surLabels.append(x)


plt.pie(van, labels=vanLabels, normalize=False)
plt.title("Vancouver")
plt.show()
plt.pie(burn, labels=burnLabels, normalize=False)
plt.title("Burnaby")
plt.show()
plt.pie(sur, labels=surLabels, normalize=False)
plt.title("Surrey")
plt.show()





#Checking all the different data between the three main cities in BC 
#There are alot of interesting cities in BC, but these three I feel like have similar temperature and road conditions,
#so it would be interesting to study the different car variables and try to understand them.<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1450837021358476, 'fraction_numerical': 0.014046565326149701, 'mean_word_length': 5.202863961813843, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '656731', 'license': 'MIT', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1552, 'n_words': 508, 'path': 'analysis/ali/milestone2.ipynb', 'repo_name': 'data301-2021-summer2/project-group5', 'size': '5197'}