Hi so I've just started learning python.And I am trying to learn pandas and I have this doubt on how to find the unique start and stop values in a data frame.Can someone help me out here
            Asked
            
        
        
            Active
            
        
            Viewed 590 times
        
    -2
            
            
        - 
                    Can you provide an example of your dataframe and the expected output? You can also read [how to write good questions for pandas](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples), this makes it much easier to help you ;) – mozway Jul 30 '21 at 11:26
1 Answers
0
            
            
        As you did not provide an example dataset, let's assume this one:
import numpy as np
np.random.seed(1)
df = pd.DataFrame({'start': np.random.randint(0,10,5),
                   'stop':  np.random.randint(0,10,5),
                  }).T.apply(sorted).T
   start  stop
0      0     5
1      1     8
2      7     9
3      5     6
4      0     9
To get unique values for a given column (here start):
>>> df['start'].unique()
array([0, 1, 7, 5])
For all columns at once:
>>> df.apply(pd.unique, result_type='reduce')
start    [0, 1, 7, 5]
stop     [5, 8, 9, 6]
dtype: object
 
    
    
        mozway
        
- 194,879
- 13
- 39
- 75
