It seems to me that you need to join both lists first, and then create Seriesand last value_counts:
print (df)
names Class Category label Class1
0 ram A Red one E
1 ravi A Red two G
2 gopal B Green three B
my_list1=["Category"]
my_list2=["Class", "Class1"]
df = df[my_list1 + my_list2].apply('.'.join, axis=1).value_counts()
print (df)
Red.A.E 1
Red.A.G 1
Green.B.B 1
dtype: int64
More details:
print (df[my_list1 + my_list2])
Category Class Class1
0 Red A E
1 Red A G
2 Green B B
print (df[my_list1 + my_list2].apply('.'.join, axis=1))
0 Red.A.E
1 Red.A.G
2 Green.B.B
dtype: object
source
share