From 4d8fa22b134addee654a1f5ed47a9c76d01b0209 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=9F=E9=9A=86=E6=A3=AE?=
<15469302+tong-longsen@user.noreply.gitee.com>
Date: Thu, 20 Mar 2025 09:37:06 +0800
Subject: [PATCH 1/7] 19numpy-ex3
---
.idea/.gitignore | 3 ++
.../inspectionProfiles/profiles_settings.xml | 6 +++
.idea/misc.xml | 7 +++
.idea/modules.xml | 8 +++
.idea/numpy-ex3.iml | 14 ++++++
.idea/vcs.xml | 6 +++
china.py | 50 ++++++++++++++-----
7 files changed, 81 insertions(+), 13 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/numpy-ex3.iml
create mode 100644 .idea/vcs.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..7341c48
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..be364f5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/numpy-ex3.iml b/.idea/numpy-ex3.iml
new file mode 100644
index 0000000..c2f299e
--- /dev/null
+++ b/.idea/numpy-ex3.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/china.py b/china.py
index 59e5547..828a33f 100644
--- a/china.py
+++ b/china.py
@@ -1,51 +1,75 @@
import numpy as np
import csv
+
def load_data(file_path):
"""
Load repository data and calculate activity metrics
Columns: repo_name,owner,stars,forks,language,created_at,last_commit,description
Return: 2D NumPy array of shape (repos, 3) containing [stars, forks, active_days]
-
+
加载仓库数据并计算活跃天数
列:仓库名称,所有者,星标,分支,语言,创建时间,最后提交,描述
返回:形状为(仓库数, 3)的数组,包含[星标数, 分支数, 活跃天数]
"""
- pass
+ data = []
+ with open(file_path, 'r', encoding='utf-8') as file:
+ reader = csv.reader(file)
+ next(reader) # 跳过标题行
+ for row in reader:
+ stars = int(row[2])
+ forks = int(row[3])
+ created_at = np.datetime64(row[5])
+ last_commit = np.datetime64(row[6])
+ active_days = (last_commit - created_at).astype(float)
+ data.append([stars, forks, active_days])
+ return np.array(data)
+
def calculate_statistics(data):
"""
Calculate repository metrics statistics
Return: Dictionary containing {
'means': [stars_mean, forks_mean, days_mean],
- 'medians': [stars_median, forks_median, days_median],
- 'variances': [stars_var, forks_var, days_var],
- 'stds': [stars_std, forks_std, days_std]
+ 'medians': [stars_median, forks_median, days_median],
+ 'variances': [stars_var, forks_var, days_var],
+ 'stds': [stars_std, forks_std, days_std]
}
-
+
计算仓库指标统计量
返回:包含平均值、中位数、方差、标准差的字典
"""
- pass
+ means = np.round(np.mean(data, axis=0), 1)
+ medians = np.round(np.median(data, axis=0), 1)
+ variances = np.round(np.var(data, axis=0), 1)
+ stds = np.round(np.std(data, axis=0), 1)
+ return {
+ 'means': means,
+ 'medians': medians,
+ 'variances': variances,
+ 'stds': stds
+ }
+
def print_results(stats):
"""
Print formatted results with proper indentation
-
+
按严格格式打印结果,保持正确缩进
"""
metrics = ['Stars', 'Forks', 'Active Days']
- for metric, mean, med, var, std in zip(metrics,
- stats['means'],
- stats['medians'],
- stats['variances'],
- stats['stds']):
+ for metric, mean, med, var, std in zip(metrics,
+ stats['means'],
+ stats['medians'],
+ stats['variances'],
+ stats['stds']):
print(f"{metric}:")
print(f" Average: {mean:.1f}")
print(f" Median: {med:.1f}")
print(f" Variance: {var:.1f}")
print(f" Standard Deviation: {std:.1f}")
+
repo_data = load_data('china-repos.csv')
stats = calculate_statistics(repo_data)
print_results(stats)
\ No newline at end of file
--
Gitee
From 3abd4d682fe9607b48818dee5d9b0738dfb3fd60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B1=A4=E7=BF=BC=E5=98=89?=
<15469290+t-yj28@user.noreply.gitee.com>
Date: Fri, 28 Mar 2025 10:45:51 +0800
Subject: [PATCH 2/7] finish pakistan.py
---
.idea/.name | 1 +
1 file changed, 1 insertion(+)
create mode 100644 .idea/.name
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..e36890d
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+pakistan.py
\ No newline at end of file
--
Gitee
From 7946a1e47993209c9756ce4d7b4f0214691351c0 Mon Sep 17 00:00:00 2001
From: Tang Yijia <15469290+t-yj28@user.noreply.gitee.com>
Date: Fri, 28 Mar 2025 11:07:01 +0800
Subject: [PATCH 3/7] Removed .idea folder
---
.idea/.gitignore | 3 ---
.idea/.name | 1 -
.idea/inspectionProfiles/profiles_settings.xml | 6 ------
.idea/misc.xml | 7 -------
.idea/modules.xml | 8 --------
.idea/numpy-ex3.iml | 14 --------------
.idea/vcs.xml | 6 ------
7 files changed, 45 deletions(-)
delete mode 100644 .idea/.gitignore
delete mode 100644 .idea/.name
delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/numpy-ex3.iml
delete mode 100644 .idea/vcs.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index 26d3352..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-# Default ignored files
-/shelf/
-/workspace.xml
diff --git a/.idea/.name b/.idea/.name
deleted file mode 100644
index e36890d..0000000
--- a/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-pakistan.py
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
deleted file mode 100644
index 105ce2d..0000000
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index 7341c48..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index be364f5..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/numpy-ex3.iml b/.idea/numpy-ex3.iml
deleted file mode 100644
index c2f299e..0000000
--- a/.idea/numpy-ex3.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
deleted file mode 100644
index 35eb1dd..0000000
--- a/.idea/vcs.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
--
Gitee
From 68ab39a2e1600df072eeb8f460fd7cb9d2445fae Mon Sep 17 00:00:00 2001
From: Tang Yijia <15469290+T-Yj28@user.noreply.gitee.com>
Date: Wed, 9 Apr 2025 03:19:15 +0000
Subject: [PATCH 4/7] add Tang-Yijia.md.
Signed-off-by: Tang Yijia <15469290+T-Yj28@user.noreply.gitee.com>
---
Tang-Yijia.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Tang-Yijia.md
diff --git a/Tang-Yijia.md b/Tang-Yijia.md
new file mode 100644
index 0000000..5b58b96
--- /dev/null
+++ b/Tang-Yijia.md
@@ -0,0 +1 @@
+# Tang yijia
\ No newline at end of file
--
Gitee
From 22063f13a7999b197013e1a20e10567f44e86bb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BD=9F=E9=9A=86=E6=A3=AE?=
<15469302+tong-longsen@user.noreply.gitee.com>
Date: Wed, 9 Apr 2025 03:25:24 +0000
Subject: [PATCH 5/7] add tls.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 佟隆森 <15469302+tong-longsen@user.noreply.gitee.com>
---
tls | 1 +
1 file changed, 1 insertion(+)
create mode 100644 tls
diff --git a/tls b/tls
new file mode 100644
index 0000000..2a3b557
--- /dev/null
+++ b/tls
@@ -0,0 +1 @@
+Tong Longsen
\ No newline at end of file
--
Gitee
From ee30ef1050c2388baea5b83129d83284985c411d Mon Sep 17 00:00:00 2001
From: Tang Yijia <15469290+T-Yj28@user.noreply.gitee.com>
Date: Wed, 9 Apr 2025 03:27:58 +0000
Subject: [PATCH 6/7] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20Tang?=
=?UTF-8?q?-Yijia.md?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Tang-Yijia.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 Tang-Yijia.md
diff --git a/Tang-Yijia.md b/Tang-Yijia.md
deleted file mode 100644
index 5b58b96..0000000
--- a/Tang-Yijia.md
+++ /dev/null
@@ -1 +0,0 @@
-# Tang yijia
\ No newline at end of file
--
Gitee
From 291ffc1ad65e1f4bcec9b7620dbacaa157f5eaa9 Mon Sep 17 00:00:00 2001
From: Tang Yijia <15469290+T-Yj28@user.noreply.gitee.com>
Date: Wed, 9 Apr 2025 03:28:30 +0000
Subject: [PATCH 7/7] add Tang-Yijia.md.
Signed-off-by: Tang Yijia <15469290+T-Yj28@user.noreply.gitee.com>
---
Tang-Yijia.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 Tang-Yijia.md
diff --git a/Tang-Yijia.md b/Tang-Yijia.md
new file mode 100644
index 0000000..a46d452
--- /dev/null
+++ b/Tang-Yijia.md
@@ -0,0 +1 @@
+# Tang Yijia
\ No newline at end of file
--
Gitee