0

I have a datafarme with the following set up.

Product Clol1   Col2    Col3
pen       2     5       8
paper     6     7       4
shrpener  0     7       9

I want create list with the values for the index. = "paper". Out put would be [6,7,4]

How can I do it?

Logica
  • 981
  • 3
  • 16
greenking
  • 151
  • 1
  • 9

2 Answers2

1

You could transpose your DataFrame and then select the desired column (ex row):

transposed_df = df.transpose()
result = transposed_df['paper']
Carsten
  • 2,325
  • 1
  • 11
  • 24
1

Select row by label with DataFrame.loc and convert Series to list, I think transpose is not necessary (and also slowier):

out = df.loc['paper'].tolist()
jezrael
  • 729,927
  • 78
  • 1,141
  • 1,090