I'd like to get a unique of a series of a dataframe while preserving its index:
In Particular i have an datframe with two columns:'Stock' and 'Company Name'.
I'm using the follow code:
lot = titoli1['Stock'].unique()
but the returns is a unique serie but i want both series value related on unique, stock, value.
Thank you in advance for youre time spented!
CodePudding user response:
I guess you are looking for this,
df[~df['col'].duplicated(keep='first')]
Sample Input:
col
0 1
1 2
2 3
3 1
4 2
Sample Output:
col
0 1
1 2
2 3