Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I'd like to get a unique of a series of a dataframe while preserving its index

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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!

>Solution :

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading