{ "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 }