-
Notifications
You must be signed in to change notification settings - Fork 0
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
# absolute path till parent folder | ||
abs_path = os.getcwd() | ||
path_array = abs_path.split("/") | ||
path_array = path_array[:len(path_array)-1] | ||
path_array = path_array[:-1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
homefolder_path = "" | ||
for i in path_array[1:]: | ||
homefolder_path = homefolder_path + "/" + i | ||
|
@@ -58,7 +58,7 @@ | |
# In[51]: | ||
|
||
# saving the plot | ||
g.savefig((abs_path + "/Plots/brand-vehicleCount.png")) | ||
g.savefig(f"{abs_path}/Plots/brand-vehicleCount.png") | ||
|
||
|
||
# ## Average price for vehicles based on the type of vehicle as well as on the type of gearbox | ||
|
@@ -75,7 +75,7 @@ | |
# In[64]: | ||
|
||
# saving the plot | ||
fig.savefig((abs_path + "/Plots/vehicletype-gearbox-price.png")) | ||
fig.savefig(f"{abs_path}/Plots/vehicletype-gearbox-price.png") | ||
|
||
|
||
# In[ ]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
# absolute path till parent folder | ||
abs_path = os.getcwd() | ||
path_array = abs_path.split("/") | ||
path_array = path_array[:len(path_array)-1] | ||
path_array = path_array[:-1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
homefolder_path = "" | ||
for i in path_array[1:]: | ||
homefolder_path = homefolder_path + "/" + i | ||
|
@@ -55,7 +55,7 @@ | |
# In[8]: | ||
|
||
# saving the plot | ||
fig.savefig((abs_path + "/Plots/vehicletype-fueltype-price.png")) | ||
fig.savefig(f"{abs_path}/Plots/vehicletype-fueltype-price.png") | ||
|
||
|
||
# ## Average power of a vehicle by vehicle type and gearbox type | ||
|
@@ -74,7 +74,7 @@ | |
# In[19]: | ||
|
||
# saving the plot | ||
fig.savefig((abs_path + "/Plots/vehicletype-fueltype-power.png")) | ||
fig.savefig(f"{abs_path}/Plots/vehicletype-fueltype-power.png") | ||
|
||
|
||
# In[ ]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
# absolute path till parent folder | ||
abs_path = os.getcwd() | ||
path_array = abs_path.split("/") | ||
path_array = path_array[:len(path_array)-1] | ||
path_array = path_array[:-1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
homefolder_path = "" | ||
for i in path_array[1:]: | ||
homefolder_path = homefolder_path + "/" + i | ||
|
@@ -69,7 +69,7 @@ | |
|
||
# In[12]: | ||
|
||
fig.savefig((abs_path + "/Plots/heatmap-price-brand-vehicleType.png")) | ||
fig.savefig(f"{abs_path}/Plots/heatmap-price-brand-vehicleType.png") | ||
|
||
|
||
# In[13]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
# absolute path till parent folder | ||
abs_path = os.getcwd() | ||
path_array = abs_path.split("/") | ||
path_array = path_array[:len(path_array)-1] | ||
path_array = path_array[:-1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
homefolder_path = "" | ||
for i in path_array[1:]: | ||
homefolder_path = homefolder_path + "/" + i | ||
|
@@ -71,13 +71,15 @@ | |
fig, ax = plt.subplots(figsize=(8,5)) | ||
sns.set_palette(sns.xkcd_palette(colors)) | ||
sns.stripplot(x="vehicleType", y="NoOfDaysOnline", hue="gearbox", split=True, data=frame,size=8, alpha=0.5, jitter=True) | ||
ax.set_title("No of days a add is online before the vehicles of brand " + search_term + " is sold") | ||
ax.set_title( | ||
f"No of days a add is online before the vehicles of brand {search_term} is sold" | ||
) | ||
plt.show() | ||
|
||
|
||
# In[27]: | ||
|
||
fig.savefig((abs_path + "/Plots/vehicletype-NoOfDaysOnline.png")) | ||
fig.savefig(f"{abs_path}/Plots/vehicletype-NoOfDaysOnline.png") | ||
|
||
|
||
# In[ ]: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,13 +305,12 @@ | |
|
||
# creating folder structure as per brand of vehicle | ||
fileName = abs_path + "/ShellScripts/CreateFolder.sh" | ||
file = open(fileName, "w+") | ||
baseString = "mkdir -p " + abs_path + "/CleanData/DataForAnalysis/" | ||
for b in list(t["brand"].unique()): | ||
newString = baseString + b + "\n" | ||
file.write(newString) | ||
file.write("mkdir -p " + abs_path + "/CleanData/CleanedDataSet") | ||
file.close() | ||
with open(fileName, "w+") as file: | ||
baseString = "mkdir -p " + abs_path + "/CleanData/DataForAnalysis/" | ||
for b in list(t["brand"].unique()): | ||
newString = baseString + b + "\n" | ||
file.write(newString) | ||
file.write("mkdir -p " + abs_path + "/CleanData/CleanedDataSet") | ||
Comment on lines
-308
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
st = os.stat(fileName) | ||
os.chmod(fileName, st.st_mode | stat.S_IEXEC) | ||
subprocess.call(fileName,shell=True) | ||
|
@@ -328,14 +327,29 @@ | |
|
||
# splitting the the records based on brand and vehicleType | ||
fileName = abs_path + "/ShellScripts/CreateFiles.sh" | ||
file = open(fileName, "w+") | ||
baseString_before = '''awk 'BEGIN{FS=OFS=","} FNR == 1 {print} ''' | ||
baseString_after = " {print}' " + abs_path + "/CleanData/CleanedDataSet/cleaned_autos.csv" + " >> " + abs_path + "/CleanData/DataForAnalysis/" | ||
for b in list(df["brand"].unique()): | ||
for typ in list(df[df["brand"] == b]["vehicleType"].unique()): | ||
newString = baseString_before + '$15 == ' + '"' + b + '"' + ' && $7 == ' + '"' + typ + '"' + baseString_after + b + "/" + b + "_" + typ + ".csv" + "\n" | ||
file.write(newString) | ||
file.close() | ||
with open(fileName, "w+") as file: | ||
baseString_before = '''awk 'BEGIN{FS=OFS=","} FNR == 1 {print} ''' | ||
baseString_after = " {print}' " + abs_path + "/CleanData/CleanedDataSet/cleaned_autos.csv" + " >> " + abs_path + "/CleanData/DataForAnalysis/" | ||
for b in list(df["brand"].unique()): | ||
for typ in list(df[df["brand"] == b]["vehicleType"].unique()): | ||
newString = ( | ||
f'{baseString_before}$15 == "' | ||
+ b | ||
+ '"' | ||
+ ' && $7 == ' | ||
+ '"' | ||
+ typ | ||
+ '"' | ||
+ baseString_after | ||
+ b | ||
+ "/" | ||
+ b | ||
+ "_" | ||
+ typ | ||
+ ".csv" | ||
+ "\n" | ||
) | ||
file.write(newString) | ||
st = os.stat(fileName) | ||
os.chmod(fileName, st.st_mode | stat.S_IEXEC) | ||
subprocess.call(fileName,shell=True) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines
32-100
refactored with the following changes:simplify-negative-index
)use-fstring-for-concatenation
)