I have a series object (1 column of a DataFrame) and would like to extract the value of the first element. Is there a way to do this simply without converting to a list and without knowing the key? Or is the only way to access it by converting it to a list first using tolist()[n]?
            Asked
            
        
        
            Active
            
        
            Viewed 2.0k times
        
    6
            
            
         
    
    
        Moppentapper
        
- 299
- 2
- 4
- 10
1 Answers
16
            I think you can use iloc:
print df
  col
0   a
1   b
2   c
3   d
4   e
print df.iloc[0]
col    a
Name: 0, dtype: object
 
    
    
        jezrael
        
- 822,522
- 95
- 1,334
- 1,252
- 
                    Thanks! When I was looking around the web I found the `iloc()` function, which returns an indexer, but not the value. Using `iloc[n]` with the square brackets works. No need for the `.values`. – Moppentapper Apr 19 '16 at 07:02