-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
4,242 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
data/*.csv | ||
|
||
!data/r1.csv | ||
!data/r2.csv | ||
!data/r3.csv | ||
!data/r4.csv |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import os | ||
|
||
CHOSEN_DATE: str = '2018-09-01' | ||
plt.rcParams['font.sans-serif'] = ['SimHei'] | ||
|
||
def get_path(filename: str) -> str: | ||
return os.path.join(os.path.dirname(os.getcwd()), 'data', filename) | ||
|
||
|
||
def read_csv() -> pd.DataFrame: | ||
r5 = pd.read_csv(get_path("r5.csv")) | ||
r5['start_time'] = pd.to_datetime(r5['start_time']) | ||
r5['end_time'] = pd.to_datetime(r5['end_time']) | ||
|
||
return r5 | ||
|
||
|
||
def choose_section(r5: pd.DataFrame) -> tuple[str, str, str]: | ||
sections = r5.groupby('section')['percentage'].mean().sort_values(ascending=False) | ||
selected_sections = (sections.index[0], sections.index[len(sections) // 3], sections.index[len(sections) // 2]) | ||
return selected_sections | ||
|
||
|
||
def plot(r5: pd.DataFrame, selected_sections: tuple[str, str, str]) -> None: | ||
plt.figure(figsize=(15, 8)) | ||
|
||
colors = ('red', 'green', 'blue') | ||
for i, section in enumerate(selected_sections): | ||
section_data: pd.Series = r5[r5['section'] == section] | ||
daily_data: pd.Series = section_data[section_data['start_time'].dt.strftime('%Y-%m-%d') == CHOSEN_DATE] | ||
final_data: pd.Series = daily_data[['start_time', 'end_time', 'percentage']] | ||
|
||
plt.plot(final_data['start_time'], | ||
final_data['percentage'], | ||
marker='o', | ||
color=colors[i], | ||
label=section) | ||
|
||
plt.title(f'Three Sections Percentage in {CHOSEN_DATE}') | ||
plt.xlabel('Time') | ||
plt.ylabel('Percentage(%)') | ||
plt.grid(True) | ||
plt.legend() | ||
plt.xticks(rotation=45) | ||
|
||
plt.tight_layout() | ||
|
||
plt.savefig(get_path('parking_utilization.png')) | ||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
result5 = read_csv() | ||
selected = choose_section(result5) | ||
plot(result5, selected) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# main packages | ||
pyspark~=3.5.3 | ||
ipykernel~=6.29.5 | ||
|
||
# for task 5 subtask only | ||
matplotlib~=3.9 | ||
pandas~=2.2.3 |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
section,count | ||
科技南一路,92 | ||
高新南九道,26 | ||
创业路(南油段),72 | ||
文心四路,24 | ||
高新南七道,41 | ||
招商路(蛇口西段),61 | ||
科技南十路,29 | ||
后海大道辅道(蛇口北段),58 | ||
登良路,29 | ||
学府路(前海段),11 | ||
工业九路,50 | ||
文心三路,12 | ||
文心一路,13 | ||
荔园路(蛇口西段),70 | ||
荔园路(蛇口东段),54 | ||
高新南环路,240 | ||
四海路,55 | ||
科技南路,87 | ||
文心五路,14 | ||
海德二道,42 | ||
中心路(后海湾段),63 | ||
金世纪路,19 | ||
创业路辅道,43 | ||
文心六路,58 | ||
科技南十二路,10 | ||
高新南十一道,60 | ||
高新南十道,73 | ||
龙城路,31 | ||
南头街,21 | ||
海月路(东段),19 | ||
高新南五道,18 | ||
海德一道,51 | ||
高新南三道,22 | ||
南新路,23 | ||
海德二道(南油段),45 | ||
文心二路,30 | ||
海德三道,46 | ||
常兴路,66 | ||
创业路(后海湾段),18 | ||
华明路,3 | ||
高新南四道,26 | ||
后海大道辅道(后海段),80 | ||
海德一道(后海湾段),26 |
Oops, something went wrong.