python数据清洗-区分excel两列不同的值

 pandas和SQL数据分析实战视频教程

https://study.163.com/course/courseMain.htm?courseId=1006383008&share=2&shareId=400000000398149

A列在B列中不存在的值

# -*- coding: utf-8 -*-
"""
Created on Thu Jun 23 10:33:27 2016

@author: Administrator
"""

import xlrd
fileName="省份处理.xlsx"

#获取一个excel内首页表格
def Get_sheet1_from_oneExcel(excelFileName):
    wb=xlrd.open_workbook(excelFileName)
    sheet=wb.sheets()[0]
    return sheet
    
    
sheet=Get_sheet1_from_oneExcel(fileName)
list_columnA=sheet.col_values(0)
list_columnB=sheet.col_values(1)

diffrence_list=[]
for i in list_columnA:
    if i=="":
        continue
    if i not in list_columnB:
        diffrence_list.append(i)
        
'''
diffrence_list
Out[47]: ['总局']

'''

print(diffrence_list)

  

 

 https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章)

 


 

原文地址:https://www.cnblogs.com/webRobot/p/5610070.html