python實(shí)現(xiàn)查找excel里某一列重復(fù)數(shù)據(jù)并且剔除后打印的方法
本文實(shí)例講述了python實(shí)現(xiàn)查找excel里某一列重復(fù)數(shù)據(jù)并且剔除后打印的方法。分享給大家供大家參考。具體分析如下:
在python里面excel的簡單讀寫操作我這里推薦使用xlrd(特別是讀操作)
import xlrd
def open_excel(fileName="simple.xls"):
try:
fileHandler = xlrd.open_workbook(fileName)
return fileHandler
except Exception, e:
print str(e)
def scan_excel(sheet_name1=u'Sheet1'):
handler = open_excel()
page = handler.sheet_by_name(sheet_name1)
return page
def trim_cols(index=0):
page = scan_excel()
col1 = page.col_values(index)
col2 = []
for item in col1:
if item not in col2:
col2.append(item)
print col1
print col2
def main():
trim_cols()
if __name__ == "__main__":
main()
輸出結(jié)果:
[1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0] [1.0, 2.0, 3.0, 4.0]
希望本文所述對大家的Python程序設(shè)計有所幫助。
- Python實(shí)現(xiàn)去除Excel重復(fù)數(shù)據(jù)并統(tǒng)計重復(fù)次數(shù)
- Python?生成多行重復(fù)數(shù)據(jù)的方法實(shí)現(xiàn)
- python列表返回重復(fù)數(shù)據(jù)的下標(biāo)
- Python對多屬性的重復(fù)數(shù)據(jù)去重實(shí)例
- python Django批量導(dǎo)入不重復(fù)數(shù)據(jù)
- python中查找excel某一列的重復(fù)數(shù)據(jù) 剔除之后打印
- Python-pandas返回重復(fù)數(shù)據(jù)的index問題
相關(guān)文章
Python使用Pandas庫實(shí)現(xiàn)MySQL數(shù)據(jù)庫的讀寫
這篇文章主要介紹了Python使用Pandas庫實(shí)現(xiàn)MySQL數(shù)據(jù)庫的讀寫 ,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07
如何使用pytorch實(shí)現(xiàn)LocallyConnected1D
由于LocallyConnected1D是Keras中的函數(shù),為了用pytorch實(shí)現(xiàn)LocallyConnected1D并在960×33的數(shù)據(jù)集上進(jìn)行訓(xùn)練和驗(yàn)證,本文分步驟給大家介紹如何使用pytorch實(shí)現(xiàn)LocallyConnected1D,感興趣的朋友一起看看吧2023-09-09
Python操作Mongodb數(shù)據(jù)庫的方法小結(jié)
這篇文章主要介紹了Python操作Mongodb數(shù)據(jù)庫的方法,結(jié)合實(shí)例形式總結(jié)分析了Python針對MongoDB數(shù)據(jù)庫的基本模塊導(dǎo)入、連接、增刪改查及排序等相關(guān)操作技巧,需要的朋友可以參考下2019-09-09
Python如何實(shí)現(xiàn)動態(tài)數(shù)組
這篇文章主要介紹了Python如何實(shí)現(xiàn)動態(tài)數(shù)組,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-11-11
在python下使用tensorflow判斷是否存在文件夾的實(shí)例
今天小編就為大家分享一篇在python下使用tensorflow判斷是否存在文件夾的實(shí)例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06
Python+Pygame實(shí)現(xiàn)趣味足球游戲
這篇文章主要為大家分享了一個基于Python和Pygame實(shí)現(xiàn)的一個趣味足球游戲,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)Python有一定幫助,需要的可以參考一下2022-05-05

