first commit
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "bc441afe",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"df = pd.read_excel('重新分班模板 (3).xlsx')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "bd93b7eb",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df.sort_values(by='新班级',inplace=True)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "83d3f4d5",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m在当前单元格或上一个单元格中执行代码时 Kernel 崩溃。\n",
|
||||
"\u001b[1;31m请查看单元格中的代码,以确定故障的可能原因。\n",
|
||||
"\u001b[1;31m单击<a href='https://aka.ms/vscodeJupyterKernelCrash'>此处</a>了解详细信息。\n",
|
||||
"\u001b[1;31m有关更多详细信息,请查看 Jupyter <a href='command:jupyter.viewOutput'>log</a>。"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df.to_excel('重新分班模板 (4).xlsx',index=False)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+17619
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,206 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "d99d999d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "955684bc",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.read_excel(\"./2025级需要选课775+7.xlsx\", usecols=['学号', '姓名', '性别'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "bc5324c0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "6a622610",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"row_strings = set()\n",
|
||||
"for _, row in df.iterrows():\n",
|
||||
" row_str = f\"{row['学号']}{row['姓名']}{row['性别']}\"\n",
|
||||
" row_strings.add(row_str)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "c2b0ab79",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(782, 3)"
|
||||
]
|
||||
},
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "e5f90213",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"782"
|
||||
]
|
||||
},
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(row_strings)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "0ec9fe0a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df1 = pd.read_excel(\"./本部简易手环学生信息 .xls\", usecols=['学号', '姓名', '性别'],skiprows=1)\n",
|
||||
"row_strings1 = set()\n",
|
||||
"for _, row in df.iterrows():\n",
|
||||
" row_str = f\"{row['学号']}{row['姓名']}{row['性别']}\"\n",
|
||||
" row_strings1.add(row_str)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "75d2483a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df1 = pd.read_excel(\"./本部蓝牙手环学生信息.xls\", usecols=['学号', '姓名', '性别'],skiprows=1)\n",
|
||||
"for _, row in df.iterrows():\n",
|
||||
" row_str = f\"{row['学号']}{row['姓名']}{row['性别']}\"\n",
|
||||
" row_strings1.add(row_str)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "e5180f79",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"set()"
|
||||
]
|
||||
},
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"row_strings - row_strings1 "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "e87426b4",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"set()"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"row_strings1 -row_strings "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "8cdc458f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"782"
|
||||
]
|
||||
},
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"len(row_strings1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "95b416db",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "9ec6ebc2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "413b2f9f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.read_excel('学生信息.xlsx',skiprows=1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "31be9769",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "dd627675",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/html": [
|
||||
"<div>\n",
|
||||
"<style scoped>\n",
|
||||
" .dataframe tbody tr th:only-of-type {\n",
|
||||
" vertical-align: middle;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe tbody tr th {\n",
|
||||
" vertical-align: top;\n",
|
||||
" }\n",
|
||||
"\n",
|
||||
" .dataframe thead th {\n",
|
||||
" text-align: right;\n",
|
||||
" }\n",
|
||||
"</style>\n",
|
||||
"<table border=\"1\" class=\"dataframe\">\n",
|
||||
" <thead>\n",
|
||||
" <tr style=\"text-align: right;\">\n",
|
||||
" <th></th>\n",
|
||||
" <th>学号</th>\n",
|
||||
" <th>姓名</th>\n",
|
||||
" <th>性别</th>\n",
|
||||
" <th>年级</th>\n",
|
||||
" <th>班级</th>\n",
|
||||
" <th>账户名</th>\n",
|
||||
" <th>手环号</th>\n",
|
||||
" <th>通/住校</th>\n",
|
||||
" </tr>\n",
|
||||
" </thead>\n",
|
||||
" <tbody>\n",
|
||||
" <tr>\n",
|
||||
" <th>0</th>\n",
|
||||
" <td>847613</td>\n",
|
||||
" <td>曾笙</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>847613CDSPTSZX</td>\n",
|
||||
" <td>3722606215</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>1</th>\n",
|
||||
" <td>205240217</td>\n",
|
||||
" <td>郭靖</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>0班</td>\n",
|
||||
" <td>205240217CDSPTSZX</td>\n",
|
||||
" <td>22802380</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>2</th>\n",
|
||||
" <td>2024240217</td>\n",
|
||||
" <td>黄蓉</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>2024240217CDSPTSZX</td>\n",
|
||||
" <td>3108630769</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>3</th>\n",
|
||||
" <td>20250011</td>\n",
|
||||
" <td>曾曦蕊</td>\n",
|
||||
" <td>女</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250011CDSPTSZX</td>\n",
|
||||
" <td>22830060</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>4</th>\n",
|
||||
" <td>20250012</td>\n",
|
||||
" <td>曾星睿</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250012CDSPTSZX</td>\n",
|
||||
" <td>3108363489</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>...</th>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" <td>...</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>780</th>\n",
|
||||
" <td>20250783</td>\n",
|
||||
" <td>彭彦晰</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250783CDSPTSZX</td>\n",
|
||||
" <td>1620701492</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>781</th>\n",
|
||||
" <td>20250802</td>\n",
|
||||
" <td>魏腾一</td>\n",
|
||||
" <td>女</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250802CDSPTSZX</td>\n",
|
||||
" <td>1618071076</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>782</th>\n",
|
||||
" <td>20250805</td>\n",
|
||||
" <td>任梓玮</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250805CDSPTSZX</td>\n",
|
||||
" <td>1619575092</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>783</th>\n",
|
||||
" <td>20250866</td>\n",
|
||||
" <td>张羽菲</td>\n",
|
||||
" <td>女</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250866CDSPTSZX</td>\n",
|
||||
" <td>1620005620</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" <tr>\n",
|
||||
" <th>784</th>\n",
|
||||
" <td>20250617</td>\n",
|
||||
" <td>杨光墨辰</td>\n",
|
||||
" <td>男</td>\n",
|
||||
" <td>2025级</td>\n",
|
||||
" <td>临时班</td>\n",
|
||||
" <td>20250617CDSPTSZX</td>\n",
|
||||
" <td>3108648785</td>\n",
|
||||
" <td>通校</td>\n",
|
||||
" </tr>\n",
|
||||
" </tbody>\n",
|
||||
"</table>\n",
|
||||
"<p>785 rows × 8 columns</p>\n",
|
||||
"</div>"
|
||||
],
|
||||
"text/plain": [
|
||||
" 学号 姓名 性别 年级 班级 账户名 手环号 通/住校\n",
|
||||
"0 847613 曾笙 男 2025级 临时班 847613CDSPTSZX 3722606215 通校\n",
|
||||
"1 205240217 郭靖 男 2025级 0班 205240217CDSPTSZX 22802380 通校\n",
|
||||
"2 2024240217 黄蓉 男 2025级 临时班 2024240217CDSPTSZX 3108630769 通校\n",
|
||||
"3 20250011 曾曦蕊 女 2025级 临时班 20250011CDSPTSZX 22830060 通校\n",
|
||||
"4 20250012 曾星睿 男 2025级 临时班 20250012CDSPTSZX 3108363489 通校\n",
|
||||
".. ... ... .. ... ... ... ... ...\n",
|
||||
"780 20250783 彭彦晰 男 2025级 临时班 20250783CDSPTSZX 1620701492 通校\n",
|
||||
"781 20250802 魏腾一 女 2025级 临时班 20250802CDSPTSZX 1618071076 通校\n",
|
||||
"782 20250805 任梓玮 男 2025级 临时班 20250805CDSPTSZX 1619575092 通校\n",
|
||||
"783 20250866 张羽菲 女 2025级 临时班 20250866CDSPTSZX 1620005620 通校\n",
|
||||
"784 20250617 杨光墨辰 男 2025级 临时班 20250617CDSPTSZX 3108648785 通校\n",
|
||||
"\n",
|
||||
"[785 rows x 8 columns]"
|
||||
]
|
||||
},
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "ef0a8145",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"'1'"
|
||||
]
|
||||
},
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\" 1\".strip()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "60a3e782",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "4cb9da33",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"df = pd.read_excel('学生信息.xlsx',skiprows=1,dtype=str)\n",
|
||||
"df2 = pd.read_excel('2025级学生班级_子1.xlsx',dtype=str)\n",
|
||||
"\n",
|
||||
"学号字典 = dict(zip(df2['学号'], df2['班级'].astype(\"str\")))\n",
|
||||
"\n",
|
||||
"# 直接通过map函数添加班级列,不存在的学号用'未找到'填充\n",
|
||||
"df['班级'] = df['学号'].map(学号字典).fillna('未找到')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"id": "947a671a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"df中有但df2中没有的记录:\n",
|
||||
" 学号 姓名 性别 年级 班级 账户名 手环号 通/住校\n",
|
||||
"0 847613 曾笙 男 2025级 临时班 847613CDSPTSZX 3722606215 通校\n",
|
||||
"1 205240217 郭靖 男 2025级 0班 205240217CDSPTSZX 0022802380 通校\n",
|
||||
"2 2024240217 黄蓉 男 2025级 临时班 2024240217CDSPTSZX 3108630769 通校\n",
|
||||
"17 20250041 陈奕瑾 女 2025级 临时班 20250041CDSPTSZX 3108586721 通校\n",
|
||||
"31 20250080 杜雨欣 女 2025级 临时班 20250080CDSPTSZX 3108567745 通校\n",
|
||||
"38 20250098 冯雅琳 女 2025级 临时班 20250098CDSPTSZX 3108398001 通校\n",
|
||||
"48 20250123 郭明萱 女 2025级 临时班 20250123CDSPTSZX 3108359601 通校\n",
|
||||
"96 20250290 刘瑞泽 男 2025级 临时班 20250290CDSPTSZX 3108417121 通校\n",
|
||||
"130 20250402 苏子洛 男 2025级 临时班 20250402CDSPTSZX 3108648977 通校\n",
|
||||
"143 20250448 王晟骁 男 2025级 临时班 20250448CDSPTSZX 3108604769 通校\n",
|
||||
"153 20250475 王雅萱 女 2025级 临时班 20250475CDSPTSZX 3108626049 通校\n",
|
||||
"157 20250502 吴睿灿 男 2025级 临时班 20250502CDSPTSZX 3108654369 通校\n",
|
||||
"172 20250567 徐周塬 男 2025级 临时班 20250567CDSPTSZX 3107628913 通校\n",
|
||||
"233 20250772 李怡辰 女 2025级 临时班 20250772CDSPTSZX 3108433745 通校\n",
|
||||
"260 20258671 弋珂 女 2025级 临时班 20258671CDSPTSZX 0022681516 通校\n",
|
||||
"261 20258673 马艺诚 男 2025级 临时班 20258673CDSPTSZX 3108571633 通校\n",
|
||||
"276 20250021 陈佳逸 女 2025级 临时班 20250021CDSPTSZX 1619715284 通校\n",
|
||||
"369 20250169 黄心仪 女 2025级 临时班 20250169CDSPTSZX 1617731892 通校\n",
|
||||
"389 20250199 乐思彤 女 2025级 临时班 20250199CDSPTSZX 1619850820 通校\n",
|
||||
"419 20250246 李屹然 男 2025级 临时班 20250246CDSPTSZX 1619431076 通校\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"# 读取Excel文件,确保所有列都是字符串类型\n",
|
||||
"df = pd.read_excel('学生信息.xlsx', skiprows=1, dtype=str)\n",
|
||||
"df2 = pd.read_excel('2025级学生班级_子1.xlsx', dtype=str)\n",
|
||||
"\n",
|
||||
"# 为两个DataFrame添加唯一标识列(姓名+性别+学号)\n",
|
||||
"# 使用分隔符避免不同字段值拼接后产生歧义(例如\"张三四\"+\"男\" vs \"张三\"+\"四男\")\n",
|
||||
"df['唯一标识'] = df['姓名'] + '|' + df['性别'] + '|' + df['学号']\n",
|
||||
"df2['唯一标识'] = df2['学生姓名'] + '|' + df2['性别'] + '|' + df2['学号']\n",
|
||||
"\n",
|
||||
"# 找出df中有但df2中没有的唯一标识\n",
|
||||
"df独有标识 = df[~df['唯一标识'].isin(df2['唯一标识'])]['唯一标识']\n",
|
||||
"\n",
|
||||
"# 根据独有标识筛选出完整记录\n",
|
||||
"结果 = df[df['唯一标识'].isin(df独有标识)]\n",
|
||||
"\n",
|
||||
"# 输出结果(可以根据需要选择保留或删除'唯一标识'列)\n",
|
||||
"print(\"df中有但df2中没有的记录:\")\n",
|
||||
"print(结果.drop(columns=['唯一标识'])) # 删除临时的唯一标识列再显示"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 37,
|
||||
"id": "a383efe9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"# 读取Excel文件,确保所有列都是字符串类型\n",
|
||||
"df = pd.read_excel('学生信息.xlsx',usecols=['姓名','性别','学号'], skiprows=1, dtype=str)\n",
|
||||
"df2 = pd.read_excel('2025级学生班级_子1.xlsx',usecols=['学生姓名','性别','学号'], dtype=str)\n",
|
||||
"\n",
|
||||
"# # 为两个DataFrame添加唯一标识列(姓名+性别+学号)\n",
|
||||
"# df['唯一标识'] = df['姓名'] + '|' + df['性别'] + '|' + df['学号']\n",
|
||||
"# df2['唯一标识'] = df2['学生姓名'] + '|' + df2['性别'] + '|' + df2['学号']\n",
|
||||
"\n",
|
||||
"# # 找出df2中有但df中没有的唯一标识\n",
|
||||
"# df2独有标识 = df2[~df2['唯一标识'].isin(df['唯一标识'])]['唯一标识']\n",
|
||||
"\n",
|
||||
"# # 根据独有标识筛选出完整记录\n",
|
||||
"# 结果 = df2[df2['唯一标识'].isin(df2独有标识)]\n",
|
||||
"\n",
|
||||
"# # 输出结果\n",
|
||||
"# print(\"df2中有但df中没有的记录:\")\n",
|
||||
"# print(结果.drop(columns=['唯一标识'])) # 删除临时的唯一标识列\n",
|
||||
"row_strings= set()\n",
|
||||
"for _,row in df.iterrows():\n",
|
||||
" row_strings.add(f\"{row['姓名']}{row['性别']}{row['学号']}\")\n",
|
||||
"row_strings1 = set()\n",
|
||||
"for _,row in df2.iterrows():\n",
|
||||
" row_strings1.add(f\"{row['学生姓名']}{row['性别']}{row['学号']}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"id": "56250fbc",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"{'彭睦雅男20250832', '李沛珊女20250831', '杨槟源男20250830', '杨颜尊女20250833'}"
|
||||
]
|
||||
},
|
||||
"execution_count": 38,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"row_strings1 - row_strings"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"id": "34dae11a",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(769, 4)"
|
||||
]
|
||||
},
|
||||
"execution_count": 35,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df2.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 36,
|
||||
"id": "b8ed5e95",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"(785, 4)"
|
||||
]
|
||||
},
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"df.shape"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5a58f936",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "87b031d3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\n",
|
||||
"ip = \"http://band.hxzhxy.cn\"\n",
|
||||
"param = {\n",
|
||||
" \"username\": \"zhongwei\",\n",
|
||||
" \"password\": \"123456a\",\n",
|
||||
" \"client_id\": \"client\",\n",
|
||||
" \"grant_type\": \"password\",\n",
|
||||
" \"client_secret\": \"123456\",\n",
|
||||
"}\n",
|
||||
"data = get(url=f\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n",
|
||||
"token = data[\"access_token\"]\n",
|
||||
"header = {\n",
|
||||
" \"content-type\": \"application/json\",\n",
|
||||
" \"authorization\": f\"Bearer {token}\",\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "e8d05784",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"for i in range(1,19):\n",
|
||||
" post(f\"https://band.hxzhxy.cn/uc/class/add?access_token={token}\",json={\"gradeId\":124,\"teamId\":19,\"className\":f\"导师{i}班\",\"enabled\":True})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "4e2bc4f9",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"区域1 = [4465-4433,4432-4400,4612-4464,4372-4352,4400-4372]\n",
|
||||
"区域中间 = [4352-4304]\n",
|
||||
"区域右上 = [4260-4236,4268-4260,4236-4216,4216-4196,4276-4268,4196-4180,4180-4172,4304-4276,4172-4156,4776-4664]\n",
|
||||
"区域右下 = [4048-4000,4664-4612,4120-4048,4156-4120]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "3218ab3e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"[32, 32, 148, 20, 28] [48] [24, 8, 20, 20, 8, 16, 8, 28, 16, 112] [48, 52, 72, 36]\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(区域1,区域中间,区域右上,区域右下)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "a6ac5331",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"260\n",
|
||||
"48\n",
|
||||
"260\n",
|
||||
"208\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print(sum(区域1))\n",
|
||||
"print(sum(区域中间))\n",
|
||||
"print(sum(区域右上))\n",
|
||||
"print(sum(区域右下))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "13a25604",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"776"
|
||||
]
|
||||
},
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"sum(区域1)+sum(区域中间)+sum(区域右上)+sum(区域右下)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+22824
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,102 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "318e7588",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from requests import get,post\n",
|
||||
"import time\n",
|
||||
"ip = \"http://band.hxzhxy.cn\"\n",
|
||||
"# ip = \"http://192.168.0.244:8100\"\n",
|
||||
"\n",
|
||||
"param = {\n",
|
||||
" \"username\": \"tangchao\",\n",
|
||||
" \"password\": \"123456a\",\n",
|
||||
" \"client_id\": \"client\",\n",
|
||||
" \"grant_type\": \"password\",\n",
|
||||
" \"client_secret\": \"123456\",\n",
|
||||
"}\n",
|
||||
"data = get(url=f\"http://band.hxzhxy.cn/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n",
|
||||
"token = data[\"access_token\"]\n",
|
||||
"header = {\n",
|
||||
" \"content-type\": \"application/json\",\n",
|
||||
" \"authorization\": f\"Bearer {token}\",\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "3c046d8d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<html>\n",
|
||||
"<head><title>404 Not Found</title></head>\n",
|
||||
"<body bgcolor=\"white\">\n",
|
||||
"<center><h1>404 Not Found</h1></center>\n",
|
||||
"<hr><center>nginx/1.4.0</center>\n",
|
||||
"</body>\n",
|
||||
"</html>\n",
|
||||
"\n",
|
||||
"<html>\n",
|
||||
"<head><title>404 Not Found</title></head>\n",
|
||||
"<body bgcolor=\"white\">\n",
|
||||
"<center><h1>404 Not Found</h1></center>\n",
|
||||
"<hr><center>nginx/1.4.0</center>\n",
|
||||
"</body>\n",
|
||||
"</html>\n",
|
||||
"\n",
|
||||
"<html>\n",
|
||||
"<head><title>404 Not Found</title></head>\n",
|
||||
"<body bgcolor=\"white\">\n",
|
||||
"<center><h1>404 Not Found</h1></center>\n",
|
||||
"<hr><center>nginx/1.4.0</center>\n",
|
||||
"</body>\n",
|
||||
"</html>\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"for i in range(24,27):\n",
|
||||
" print(post(f\"{ip}/classAttendStu/createThisWeek\",headers=header,params={\"planId\":i},timeout=600).text)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "343a9e44",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.12.4"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
Reference in New Issue
Block a user