办公用脚本——疫情通打卡数据处理0218

"""
疫情通数据处理
@Author:小呼呼哈哈哈
"""
import pandas as pd
import numpy as np

file_name = "导出明细数据2021021914.csv"
Data_Source = pd.read_csv(file_name, encoding='gbk')
# print(Data_Source)
b = np.array(Data_Source)
col_Name = b[:, 0]
col_STUNum = b[:, 1]
col_Tel = b[:, 5]
col_Adderss_rough = b[:, 24]
col_Adderss_accurate = b[:, 25]

# 目标地区学生代号
def findindex(org, x, pos=-1):
    counts = org.count(x)   #先求出org中包含x的个数
    list_1 = []
    for i in range(counts):
        pos = org.index(x, pos + 1)
        list_1.append(pos)
    return list_1

col_Adderss = col_Adderss_rough.tolist()  #  将numpy数组转化为列表
org = col_Adderss

Target_location = '陕西省西安市碑林区'   # 请输出目标地区
Target_location_dis = Target_location[:3]+' '+Target_location[3:6]+' '+Target_location[6:]  # 自行修改参数
print('确定的搜索目标:\n',Target_location_dis)
Match_position = findindex(org, Target_location_dis)  # 在目标地点的学生代码list
print(Match_position)

# 判断是否有学生在目标区域
if Target_location_dis in col_Adderss_rough:
    print("有学生在目标地区附近")
else:
    print("没有学生在目标地区附近")

Match_Name = []
Match_AdreS = []
for i in Match_position:
    temp1 = col_Name[i]
    Match_Name.append(temp1)
    temp2 = col_Adderss_accurate[i]
    Match_AdreS.append(temp2)
print('在', Target_location,'的学生名单及精确地点:\n', Match_Name, '\n', Match_AdreS)

"""
未完待续
"""
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值