Skip to main content

Find duplicates in multiple lists and return their indices and values.

Tested against Windows 10 / Python 3.10 / Anaconda

pip install duplicateindexer

Find duplicates in multiple lists and return their indices and values.

This function takes multiple lists as input and finds the common elements among them. It then returns a list of dictionaries, where each dictionary corresponds to a common element. Each dictionary contains keys for the input lists (0, 1, 2, ...), and the values are nested dictionaries. These nested dictionaries have keys 'indices' and 'value', which represent the indices of the common element in the input lists and the values of that common element in the input lists, respectively.

Args:
	*args: Multiple lists containing elements to be compared.

Returns:
	List of dictionaries, where each dictionary represents a common element and its indices and values
	in the input lists.

Examples:
	>>> aa = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]
	>>> bb = [
	...     [1, 2, 3],
	...     [4, 5, 6],
	...     [7, 8, 9],
	...     [10, 11, 12],
	...     [13, 14, 15],
	...     [1, 2, 3],
	...     [4, 5, 6],
	...     [7, 8, 9],
	...     [10, 11, 12],
	...     [13, 14, 15],
	... ]
	>>> l = find_duplicates_in_multiple_lists(aa, bb)
	>>> print(l)
	[
		{
			0: {
				0: {'indices': [1], 'value': [4, 5, 6]},
				1: {'indices': [1, 6], 'value': [4, 5, 6]}
			}
		},
		{
			1: {
				0: {'indices': [0], 'value': [1, 2, 3]},
				1: {'indices': [0, 5], 'value': [1, 2, 3]}
			}
		},
		{
			2: {
				0: {'indices': [2], 'value': [7, 8, 9]},
				1: {'indices': [2, 7], 'value': [7, 8, 9]}
			}
		},
		{
			3: {
				0: {'indices': [3], 'value': [10, 11, 12]},
				1: {'indices': [3, 8], 'value': [10, 11, 12]}
			}
		}
	]

	>>> cc = list(range(1, 20))
	>>> dd = list(range(11, 30))
	>>> l1 = find_duplicates_in_multiple_lists(cc, dd)
	>>> print(l1)
	[
		{0: {0: {'indices': [10], 'value': 11}, 1: {'indices': [0], 'value': 11}}},
		{1: {0: {'indices': [11], 'value': 12}, 1: {'indices': [1], 'value': 12}}},
		{2: {0: {'indices': [12], 'value': 13}, 1: {'indices': [2], 'value': 13}}},
		{3: {0: {'indices': [13], 'value': 14}, 1: {'indices': [3], 'value': 14}}},
		{4: {0: {'indices': [14], 'value': 15}, 1: {'indices': [4], 'value': 15}}},
		{5: {0: {'indices': [15], 'value': 16}, 1: {'indices': [5], 'value': 16}}},
		{6: {0: {'indices': [16], 'value': 17}, 1: {'indices': [6], 'value': 17}}},
		{7: {0: {'indices': [17], 'value': 18}, 1: {'indices': [7], 'value': 18}}},
		{8: {0: {'indices': [18], 'value': 19}, 1: {'indices': [8], 'value': 19}}}
	]

Metadata

Release files for duplicateindexer 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for duplicateindexer 0.10
File Size Uploaded Provenance Actions
duplicateindexer-0.10.tar.gz 4.3 kB Without provenance Details for duplicateindexer-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for duplicateindexer 0.10
File Interpreter ABI Platform Actions
duplicateindexer-0.10-py3-none-any.whl Python 3 none any Details for duplicateindexer-0.10-py3-none-any.whl

Total release size: 10.7 kB

Release files / duplicateindexer-0.10.tar.gz

Download URL duplicateindexer-0.10.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
414cd47c33d027e00cc4bf4bc3212fc9c68e0c0ba0bcba810645ab888244e854
BLAKE2b-256 checksum
How to use checksums
c8c04d6cb7c01ff9459f52a969e292eb989e23782338b9ad5148799a1a4b2fa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / duplicateindexer-0.10-py3-none-any.whl

Download URL duplicateindexer-0.10-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abecd9528b0739f163eb4281847c4c1e4d220004658cbb578f882c38dbbb8ad6
BLAKE2b-256 checksum
How to use checksums
c33b46e3d5da7c95b6c7b0710e958cee03a97870485288b8d1478aac36f6bc43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Security for duplicateindexer 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page