Python Excel 去重


原文:https://blog.csdn.net/weixin_44266650/article/details/88416718
原文:https://www.icode9.com/content-1-230802.html
官方原文:https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html
官方原文:https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html



mark:不得不說python的這些庫用着真是不要太爽。。。


代碼如下

# 原文:https://blog.csdn.net/weixin_44266650/article/details/88416718
# 原文:https://www.icode9.com/content-1-230802.html
# 原文:https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_excel.html

import pandas as pd

df = pd.read_excel('test.xlsx')
print(type(df))

# inplace=True:刪掉重復的行
df.drop_duplicates(['標題'], inplace=True)

# index=False:不把索引寫入行
df.to_excel('out.xlsx', index=False)

print('去重完成')



去重前

去重后


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM