excel - 从python中的一张excel文件中查找列的不同值

标签 excel pandas python-3.8

How can I find the first column's distict values from sheet3 ?

import sys
import pandas as pd


excel_file = "dataset.xlsx"
datasets = pd.ExcelFile(excel_file)

sheet0 = pd.read_excel(datasets, 'Title Sheet')
sheet3 = pd.read_excel(excel_file, sheet_name=3, index_col=0)
sheet4 = pd.read_excel(excel_file, sheet_name=4, index_col=0)
sheet1 = pd.read_excel(excel_file, sheet_name=1, index_col=0)

customer_data = pd.concat([sheet3, sheet4, sheet1])

最佳答案

要获取特定工作表的唯一值,您可以执行以下操作:

unq = sheet3.iloc[:,0].unique()
print(unq)
要获取唯一值的计数,您可以执行以下操作:
unq = sheet3.iloc[:,0].nunique()
print(unq)

关于excel - 从python中的一张excel文件中查找列的不同值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63060824/

相关文章:

java - 如何使用 postman 或API从 "Download"文件夹下载文件

python - MultiIndex 的问题

Python Pandas : Updating row based on value from another column

python - 如何编写一个Python正则表达式来确保字符不在模式的特定位置?

jupyter-notebook - 我的 jupyter 笔记本不再执行代码

python - python 3.8 中异步内部的多处理失败(无法腌制本地对象)

VBA使用FormulaR1C1找到左边直到空格

Excel工作表的C#自动调整方法

vba - 高级过滤器错误

python - 固定 Pandas 数据框中的日期