'Pattern Clustering using Python

I wanted to recognise all the patterns data can be present in "Subset" Column of following data frame.

DataFrame-

Name    Subset    
A-1001  0
A-1001  1
A-1001  2
B-1005  3
B-1005  4
D-1015  0
D-1015  1
D-1015  2
L-650   0 
L-650   5
L-650   6
V-895   3
V-895   4

Here in this data frame, Patterns for Subsets of A-1001, D-1015 Are matching, while B-1005, V-895 have same pattern. Pattern for L-650 is different.

i.e Output Example

Pattern#    Name
1           A-1001, D-1015
2           B-1005, V-895
3           L-650

How can I recognize these patterns using Python?

P.S There may be many unknown patterns.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source