Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Analysis1/Analysis1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Author

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:

homefolder_path = ""
for i in path_array[1:]:
homefolder_path = homefolder_path + "/" + i
Expand Down Expand Up @@ -60,7 +60,7 @@
# In[33]:

# saving the plot
fig.savefig(abs_path + "/Plots/vehicle-distribution.png")
fig.savefig(f"{abs_path}/Plots/vehicle-distribution.png")


# ## Variation of the price range by the vehicle type
Expand All @@ -78,7 +78,7 @@
# In[45]:

# saving the plot
fig.savefig(abs_path + "/Plots/price-vehicleType-boxplot.png")
fig.savefig(f"{abs_path}/Plots/price-vehicleType-boxplot.png")


# ## Total count of vehicles by type available on ebay for sale
Expand All @@ -97,7 +97,7 @@
# In[54]:

# saving the plot
g.savefig(abs_path + "/Plots/count-vehicleType.png")
g.savefig(f"{abs_path}/Plots/count-vehicleType.png")


# In[ ]:
Expand Down
6 changes: 3 additions & 3 deletions Analysis2/Analysis2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 30-78 refactored with the following changes:

homefolder_path = ""
for i in path_array[1:]:
homefolder_path = homefolder_path + "/" + i
Expand Down Expand Up @@ -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
Expand All @@ -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[ ]:
Expand Down
6 changes: 3 additions & 3 deletions Analysis3/Analysis3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-77 refactored with the following changes:

homefolder_path = ""
for i in path_array[1:]:
homefolder_path = homefolder_path + "/" + i
Expand Down Expand Up @@ -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
Expand All @@ -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[ ]:
Expand Down
4 changes: 2 additions & 2 deletions Analysis4/Analysis4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-72 refactored with the following changes:

homefolder_path = ""
for i in path_array[1:]:
homefolder_path = homefolder_path + "/" + i
Expand Down Expand Up @@ -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]:
Expand Down
8 changes: 5 additions & 3 deletions Analysis5/Analysis5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 32-80 refactored with the following changes:

homefolder_path = ""
for i in path_array[1:]:
homefolder_path = homefolder_path + "/" + i
Expand Down Expand Up @@ -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[ ]:
Expand Down
44 changes: 29 additions & 15 deletions DataPreparation/DataPreparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 308-338 refactored with the following changes:

st = os.stat(fileName)
os.chmod(fileName, st.st_mode | stat.S_IEXEC)
subprocess.call(fileName,shell=True)
Expand All @@ -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)
Expand Down