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/