Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
complex sort in dataframe
#1
Hello guys!

I have a dataframe.

import pandas as pd 
data = {'num':[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
       'name':['281.3891.3891.281', 
       '3891.281.281.3891', 
       '1162.5645.5645.500835.500835.1162', 
       '5645.500835.500835.1162.1162.5645',
       '500835.1162.1162.5645.5645.500835',
       '1349.1162.1162.5645.5645.500835.500835.1349',
       '1162.5645.5645.500835.500835.1349.1349.1162',
       '5645.500835.500835.1349.1349.1162.1162.5645',
       '500835.1349.1349.1162.1162.5645.5645.500835',
       '5645.1162.1162.500835.500835.5645',
       '1162.500835.500835.5645.5645.1162',
       '500835.5645.5645.1162.1162.500835'
       ]} 
df = pd.DataFrame(data) 
print(df)
Each line in dataframe is a chain (start point = end point).
But chains are not unique. (A-B-C = B-C-A = C-A-B <> B-A-C)
I can’t catch using which methods in python I have to sort(using parallel shift) units of all chains to drop duplicates.

Could please anybody help?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo a.sort() == b.sort() all the time 3lnyn0 1 1,327 Apr-19-2022, 06:50 PM
Last Post: Gribouillis
  How to sort values descending from a row in a dataframe using python sankarachari 1 1,426 Aug-16-2021, 08:55 AM
Last Post: jamesaarr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020