Sample

Processing Duplicated Rows of 2 Dimensional Arrays using Google Apps Script

Gists

Overview

These are sample scripts for processing the duplicated rows of 2 dimensional arrays using Google Apps Script.

Description

When I use Google Spreadsheet and/or see Stackoverflow, I sometimes see the situation which is required to process the duplicated rows of 2 dimensional arrays. I thought that when the sample scripts for it have already prepared, they will be useful for other users including me. So I published this post. This sample scripts can be also used for Javascript. If this post is useful for you, I’m glad.

Element's Duplicate Number in Array at Python

Suddenly I had to need this.

This script can get the duplicate number of each element in array at Python. In this script, the duplicate number of each element is obtained and sorted by the duplicate number. This was expressed by the comprehension.

data = ['a', 'b', 'c', 'd', 'b', 'c', 'd', 'b', 'c', 'b']
result = sorted({i: data.count(i) for i in set(data)}.items(), key=lambda x: x[1], reverse=True)
print(result)

>>> [('b', 4), ('c', 3), ('d', 2), ('a', 1)]