How can I check if the array of objects have duplicate property values?

Use array.prototype.map and array.prototype.some: var values = [ { name: ‘someName1’ }, { name: ‘someName2’ }, { name: ‘someName4’ }, { name: ‘someName2’ } ]; var valueArr = values.map(function(item){ return item.name }); var isDuplicate = valueArr.some(function(item, idx){ return valueArr.indexOf(item) != idx }); console.log(isDuplicate);

.NET unique object identifier

.NET 4 and later only Good news, everyone! The perfect tool for this job is built in .NET 4 and it’s called ConditionalWeakTable<TKey, TValue>. This class: can be used to associate arbitrary data with managed object instances much like a dictionary (although it is not a dictionary) does not depend on memory addresses, so is … Read more

How to select only the first rows for each unique value of a column?

A very simple answer if you say you don’t care which address is used. SELECT CName, MIN(AddressLine) FROM MyTable GROUP BY CName If you want the first according to, say, an “inserted” column then it’s a different query SELECT M.CName, M.AddressLine, FROM ( SELECT CName, MIN(Inserted) AS First FROM MyTable GROUP BY CName ) foo … Read more

Count unique values per groups with Pandas [duplicate]

You need nunique: df = df.groupby(‘domain’)[‘ID’].nunique() print (df) domain ‘facebook.com’ 1 ‘google.com’ 1 ‘twitter.com’ 2 ‘vk.com’ 3 Name: ID, dtype: int64 If you need to strip ‘ characters: df = df.ID.groupby([df.domain.str.strip(“‘”)]).nunique() print (df) domain facebook.com 1 google.com 1 twitter.com 2 vk.com 3 Name: ID, dtype: int64 Or as Jon Clements commented: df.groupby(df.domain.str.strip(“‘”))[‘ID’].nunique() You can retain … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)