From bf41fa1ae21214a7b48706e7efdc054310f0b866 Mon Sep 17 00:00:00 2001 From: hut22412220310 Date: Wed, 21 Jan 2026 00:41:28 +0800 Subject: [PATCH] ADD file via upload --- 8.2 探索公交车刷卡数据.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 8.2 探索公交车刷卡数据.py diff --git a/8.2 探索公交车刷卡数据.py b/8.2 探索公交车刷卡数据.py new file mode 100644 index 0000000..dab1dfe --- /dev/null +++ b/8.2 探索公交车刷卡数据.py @@ -0,0 +1,22 @@ +# 代码8-1 +import pandas as pd +import os +import matplotlib.pyplot as plt + + +plt.figure(figsize=(8, 4)) +file_list = os.listdir("../data/time") +for file_name in file_list: + if file_name.split(".")[-1] == "csv": + df_time = pd.read_csv("../data/time/" + file_name) + plt.plot(df_time["date"], df_time["num"], label=file_name) + +plt.xticks([5, 10, 15, 20], ['5:00', '10:00', '15:00', '20:00']) +plt.yticks([0, 100000, 200000, 300000, 400000, 500000, 600000], + ['0', '10', '20', '30', '40', '50', '60']) +plt.rcParams['font.sans-serif'] = 'SimHei' # 设置字体为SimHei显示中文 +plt.xlabel('时间点') # fontproperties参数可以显示相应字体 +plt.ylabel('刷卡人数(单位:万)') +plt.title('图例') +plt.legend(("2014-06-09", "2014-06-10", "2014-06-11", "2014-06-12", "2014-06-13"), loc=1) +plt.show() \ No newline at end of file