6

I have this issue with heatmap from seaborn. I don't know how, but seaborn.heatmap() refuses to take in dataframe, it instead show the mentioned error. Seaborn, matplotlib and pandas is up-to-date and I'm using python 3.10 on Visual Studio. The code is just a sample code from seaborn.heatmap itself:

import pandas as pd import seaborn as sns import matplotlib.pyplot as plt flights = sns.load_dataset("flights") flights = flights.pivot("month", "year", "passengers") ax=sns.heatmap(flights) plt.show() 
3
  • Please add a trace of errors. Thanks Commented Dec 5, 2021 at 8:49
  • 2
    @Dilettant is this what you want? I'm sorry if I'm mistaken: Stack trace: > File "D:\baitaplaptrinh\lamchoi\PythonApplication1\PythonApplication1\PythonApplication1.py", line 6, in <module> (Current frame) > ax=sns.heatmap(flights) Commented Dec 5, 2021 at 9:12
  • 1
    I've been running into the same issue. It looks like something is setting np.core.numeric.dtype to None. When a dtype check occurs (part of Matplotlib's plotting), the np.core.numeric.dtype() function is called. Since this has been set to None by something, it raises the error you've noted above. Still trying to figure out how this is happening. Commented Jan 11, 2022 at 23:10

2 Answers 2

8

Use Python 3.9 (or 3.8, 3.7, 3.6) as it seems like both pandas and plt are not quite ready to be used with Python 3.10:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

I dont know if this is the right one, but in the output, it said:Stack trace: > File "D:\baitaplaptrinh\lamchoi\PythonApplication1\PythonApplication1\PythonApplication1.py", line 6, in <module> (Current frame) > ax=sns.heatmap(flights)
I'd love to, but my reputation is too low, sorry
0

I eventually solved that issue by calling the heatmap module separately: 'from seaborn import heatmap'. That had to be done even after already explicitly stating 'from seaborn import *'. Smh.

But, on the plus side, no need to downgrade to 3.9 after all.

1 Comment

Please format your code correctly.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.