Postgres unique constraint vs index

As I can understand documentation the following definitions are equivalent: create table foo ( id serial primary key, code integer, label text, constraint foo_uq unique (code, label)); create table foo ( id serial primary key, code integer, label text); create unique index foo_idx on foo using btree (code, label); However, a note in the manual … Read more

Count unique values per groups with Pandas [duplicate]

This question already has answers here: Pandas ‘count(distinct)’ equivalent (10 answers) Closed 3 years ago. I need to count unique ID values in every domain. I have data: ID, domain 123, ‘vk.com’ 123, ‘vk.com’ 123, ‘twitter.com’ 456, ‘vk.com’ 456, ‘facebook.com’ 456, ‘vk.com’ 456, ‘google.com’ 789, ‘twitter.com’ 789, ‘vk.com’ I try df.groupby([‘domain’, ‘ID’]).count() But I want … Read more

How to get distinct values from an array of objects in JavaScript?

Assuming I have the following: var array = [ {“name”:”Joe”, “age”:17}, {“name”:”Bob”, “age”:17}, {“name”:”Carl”, “age”: 35} ] What is the best way to be able to get an array of all of the distinct ages such that I get an result array of: [17, 35] Is there some way I could alternatively structure the data … Read more