'Getting error while generating heatmap in python:ValueError: Must pass 2-d input. shape=()

I am getting errors while generating maps of h3 moments in python for an image file called "image_test". The error apparently is for the shape of the values that I am getting for h3. My goal is to just take the h3 values that I get from h3[ycell][xcell] in my code and then use the values to create a red-blue heatmap in the x-y grid. The link to my code (image_stats.ipynb) in my drive is below. The code uses a file "image_test" which needs to be downloaded for code to run. https://drive.google.com/drive/folders/1gXWSuxsOHHaNV5Qv-C1f4kEUwElKMmRS?usp=sharing

The main issue might be in this snippet of the code:

for ycell in range(8):
    for xcell in range(13):
        #cells[ycell][xcell] = np.array(vz_new[(y_new == ycell) & (x_new == xcell)],dtype=object)
        cells[ycell][xcell] = vz_new[(y_new == ycell) & (x_new == xcell)]
        #[ i for i in cells[ycell][xcell] if (math.inf not in i) and (math.nan not in i) ]
        
        h3[ycell][xcell] = get_h3(cells[ycell][xcell]) 
        #print(cells[ycell][xcell])
        #print(h3[ycell][xcell])
        
        
        #print('SHAPE IS=', h3[ycell][xcell].shape)
fig, ax = plt.subplots()
# heatmap
ax=sns.heatmap(h3[ycell][xcell], cmap='RdBu')
ax.invert_yaxis()
plt.show()

Not posting full code or error here because too long, so please check google drive link for full code. Thanks for any help! Please ask for clarification if needed.

NOTE: h3 is like a list of lists. looks like the following when printed. enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source