0

I am trying to mask a pandas data frame and pass it to create a heatmap. I have used the following code

import numpy as np
import pandas as pd
import seaborn as sns

df = pd.read_csv('distance_matrix_Mult_Align.csv', index_col=0)
mask = np.zeros_like(df)
triangle_indices = np.triu_indices_from(mask)
mask[triangle_indices] = True
sns.heatmap(df, cmap="RdBu", center=0, vmin=-1, vmax=1, mask=mask)

I get an error message saying ValueError: cannot convert float NaN to intege. To check for any NaN values, I run the following code

check_for_NaN = df.isnull().values.any()
print(check_for_NaN)

The output was False. I found a post similar to mine (Pandas: ValueError: cannot convert float NaN to integer) but the dimensions of my dataframe is 640 × 640. So column-wise treatment seems impractical.

I am struggling to figure out the issue. I would really appreciate any help. Thanks!

Noob
  • 141
  • 8

1 Answers1

0

enter image description here

Your commands work for me. Can you try updating your numpy and pandas ?

anarchy
  • 3,709
  • 2
  • 16
  • 48
  • Thank you so much! I have uninstalled anaconda and then installed it again (I tried to update it multiple times with command like ``conda update conda`` ``conda install anaconda=versionNumber`` ``conda update --all`` etc. But none of these worked. How do you usually update anaconda?). Finally it's working :-) – Noob Aug 03 '21 at 08:22