I want implement purity measure in python, I have an excel file like this:
The numbers are cluster of laptops. I want to get the number of laptops per cluster like this:
can you help me??
Join Stack Overflow to learn, share knowledge, and build your career.
I want implement purity measure in python, I have an excel file like this:
The numbers are cluster of laptops. I want to get the number of laptops per cluster like this:
can you help me??
In your excel file, concatenate your two columns before analysis with python. If your data is in columns A and B in excel, you can concatenate with this formula:
=Concatenate(A1,", ",B1)
Here is the result:
Now that you have each brand combined with its cluster number, you can run a simple python script to count how many times each string appears.
Pseudocode for python:
d = dict()
For each row in concatenated column:
If string in d: #checking if dictionary key already exists for this computer-cluster combo
d[string] += 1 #add 1 if exists already
else:
d[string] = 1 #create key and assign value of 1 if key does not exist already
print(d)