I am wanting to learn how to convert a dictionary into a square matrix. From what I have read, I may need to convert this into a numpy array and then reshape it. I do not want to use reshape as I want to be able to do this based on information a user puts in. In other words, I want a code to give out a square matrix no matter how many owners and breeds are input by the user.
Note: The owners and breeds for this dictionary vary upon user input. A user can input 100 names and 50 breeds, or they can input 4 names and 5 breeds. In this example, I did four names and three dogs.
dict1 =
{'Bob VS Sarah': {'shepherd': 1,'collie': 5,'poodle': 8},
'Bob VS Ann': {'shepherd': 3,'collie': 2,'poodle': 1},
'Bob VS Jen': {'shepherd': 3,'collie': 2,'poodle': 2},
'Sarah VS Bob': {'shepherd': 3,'collie': 2,'poodle': 4},
'Sarah VS Ann': {'shepherd': 4,'collie': 6,'poodle': 3},
'Sarah VS Jen': {'shepherd': 1,'collie': 5,'poodle': 8},
'Jen VS Bob': {'shepherd': 4,'collie': 8,'poodle': 1},
'Jen VS Sarah': {'shepherd': 7,'collie': 9,'poodle': 2},
'Jen VS Ann': {'shepherd': 3,'collie': 7,'poodle': 2},
'Ann VS Bob': {'shepherd': 6,'collie': 2,'poodle': 5},
'Ann VS Sarah': {'shepherd': 0,'collie': 2,'poodle': 4},
'Ann VS Jen': {'shepherd': 2,'collie': 8,'poodle': 2},
'Bob VS Bob': {'shepherd': 3,'collie': 2,'poodle': 2},
'Sarah VS Sarah': {'shepherd': 3,'collie': 2,'poodle': 2},
'Ann VS Ann': {'shepherd': 13,'collie': 2,'poodle': 4},
'Jen VS Jen': {'shepherd': 9,'collie': 7,'poodle': 2}}
For example, I want a 4 x 4 matrix (again, the user can input any number of dog breeds so 3 breeds is not a restriction), since there are four owners.
I apologize ahead of time for not putting in what I want the end result to look like and usually I do. I am just proud of myself for making dict1 :). So the dictionary should be in a form similar to below, but I am not sure how to incorporate the different breeds. The hard part for me is that I am only needing one matrix. I also plan on using the matrix solver numpy has, hence why I am wanting to figure out how to get a square matrix from a dictionary.
Bob Sarah Ann Jen
Bob
Sarah
Ann
Jen