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
  • 977
  • 4
  • 16
greenking
  • 151
  • 3
  • 10

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,765
  • 1
  • 13
  • 28
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
  • 822,522
  • 95
  • 1,334
  • 1,252