Home > Net >  how to do count of column value and define unique or not
how to do count of column value and define unique or not

Time:04-06

If i have column of data frame, then how to define column value is unique or not enter image description here

CodePudding user response:

IIUC use numpy.where with Series.duplicated and for counts Series.map with Series.value_counts:

df['Count WFID'] = np.where(df['WFID'].duplicated(kee=False), 'not unique', 1)
df['Count WF in PD'] = df['WFID'].map(df['WFID'].value_counts())
  • Related