-1

I have a csv file. I want to separate just one column of it and develop a matrix of it and draw a heatmap plot using the matrix.

For example, if I have 20 rows in the column I would like to make 10x2 matrix, which means 10 columns per row (from first to 10th row in csv file) in matrix and then the next 10 rows should be presented as columns of 2nd row.

Then, I want to draw a heatmap plot using holoviews which represents the matrix.

Ralf
  • 16,086
  • 4
  • 44
  • 68
eli bio67
  • 1
  • 1

1 Answers1

0

First read your csv file into a dataframe as follows.

import pandas as pd
df = pd.read_csv('filename.csv')

For the purposes of an example, here's a dataframe with dummy data

df = pd.DataFrame({'a':list(range(0,20)),'b':list(range(20,40))})

Now grab column 'b', and reshape it into 10x2.

mat = df['b'].values.reshape(10,2)

Finally, generate the heatmap with some dummy names.

import holoviews as hv
hv.extension('bokeh')
hv.HeatMap((['row','names'],list(range(0,10)),mat))
Brian Keats
  • 131
  • 1
  • 11