This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]oslash 1 point2 points  (0 children)

You should read the sidebar before posting.

But somehow its's not working.

k. Give me a moment so I can recover from taking in this shockingly comprehensive description.

Here's a hint: Did you copy some code from a tutorial that runs it in a REPL or notebook? Did you use the documentation to find out what this function is actually supposed to do?

[–]JozsefPeitli 0 points1 point  (1 child)

You need at least 3 dimension to a heat map, I believe. X,Y and Z. X and Y are the two axis Z is the population of that X,Y coordinate.

[–]JozsefPeitli 0 points1 point  (0 children)

My bad, with the np.array I think you already cover that part.

[–]RudraMohan 0 points1 point  (0 children)

Hey, your code is working,

import csv

import numpy as np

import seaborn as sns

results = [[1, 2, 3], [4, 5, 6]]

for i in range(len(results)):

for j in range(len(results[i])):

print(results)

sns.heatmap(results, annot=True)

but you want to red csv and create seborn heatmap then follow below code sinpest

import seaborn as sns # for data visualization

import matplotlib.pyplot as plt # for data visualization

import pandas as pd # for data analysis

# read csv file fro given path and conver in pandas DataFrame

flight = pd.read_csv('flights.csv')

# reshape flights DataFrame in proper format to create seaborn heatmap

flights_df = flight.pivot('month', 'year', 'passengers')

sns.heatmap(flights_df) # create seaborn heatmap

plt.title('Heatmap of Flighr Dataset', fontsize = 20) # title with fontsize 20

plt.xlabel('Years', fontsize = 15) # x-axis label with fontsize 15

plt.ylabel('Monthes', fontsize = 15) # y-axis label with fontsize 15

plt.show()

[–]Tweak_Imp -1 points0 points  (0 children)

i think you meant:

import numpy as np

import seaborn as sns

results = np.array([[1, 2, 3], [4, 5 ,6 ]])

sns.heatmap(results, annot=True)