1
Hey, guys, what’s up? I am new to the machine learning study and I come here to ask for a help on how I can proceed to count how many sub-lists have the same value in an array in python numpy as the example below:
All array size is 395 sub lists.
array_1 = [[0,0,1,1,1],[0,0,0,1,1],[1,1,1,1,1],[0,1,0,1,0],[0,0,1,1,1],[0,0,0,1,1],[1,1,1,1,1],[0,1,0,1,0]]
array_2 = [[0,0,2,2,,[0,0,0,2,2],[2,2,2,2,2],[0,2,0,2,0],[0,0,2,2,2],[0,0,0,2,2],[2,2,2,2,2],[0,2,0,2,0]]
as I have to display:
column_2 countage
0,0,1,1,1 2
1,1,1,1,1 2
0,2,0,2,0 2
0,2,0,2,0 2
I tried to use that code but it didn’t work.
h = pd.DataFrame(array_1, columns=[0,1,2,3,4])
duplicateRowsDF = h.pivot_table(index=[0,1,2,3,4], aggfunc='size')
print(duplicateRowsDF)
I would like some help from colleagues because I cannot find a clear idea.