I have an Excel file (which can optionally be loaded into a database, and into an array of arrays of course) with values such as:




A
B
C




NULL
NULL
zxy


xyz
xzy
NULL


xyz
xzy
xyy


yzy
yyx
yxy


NULL
NULL
xyx


xyz
NULL
yxx




and so on.
There are thousands of values.
Is there any known algorithm to come up with all possible combinations of rows where values are not "NULL"?
For example for the table above the result would be:




A
B
C
Number of occurrences




NULL
NULL
*
2


*
*
NULL
1


*
*
*
2


*
NULL
*
1




I feel like it is a typical task, but cannot find the algorithm anywhere. Would appreciate your help a lot.

Algorithm to list all combinations from a table where data is present or NULL
If you are tempted to use pandas :
#pip install pandas
import pandas as pd

df = pd.read_excel("file.xlsx")

out = (
    df.replace(".+", "*", regex=True).fillna("NULL")
        .groupby(list(df), group_keys=False, sort=False)
        .size().reset_index(name="Number of occurrences")
)

Output :
print(out)
    
      A     B     C  Number of occurrences
0  NULL  NULL     *                      2
1     *     *  NULL                      1
2     *     *     *                      2
3     *  NULL     *                      1

