I have a python dictionary whose keys are chess board positions (64 positions) and whose values are the number of captures taken place at the board position.
OrderedDict([('a1', 552),
('a2', 1128),
('a3', 1464),
('a4', 2328),
('a5', 2304),
('a6', 2088),
('a7', 1344),
('a8', 768),
('b1', 504),
('b2', 2544),
('b3', 3480),
('b4', 5016),
...
('h5', 2136),
('h6', 1968),
('h7', 816),
('h8', 336)])
To find the most "dangerous" positions of the chessboard, I wish to plot these values onto a heatmap using seaborn. To do this, the data should be converted to a pandas dataframe or numpy array where rows range from 1 to 8 and columns from a to h (see chessboard). I need a data frame with the exact same layout of the chessboard shown.
How do I transform this "linear" data into a 2-dimensional layout?
question from:
https://stackoverflow.com/questions/66053317/how-can-i-plot-a-heatmap-from-my-python-dictionary 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…