1

I have a DataFrame like this:

df = pd.DataFrame({'orig': ['ORD', 'AUS', 'AUS'], 'dest': ['LAX', 'JFK', 'JFK']}

I'd like to be able to turn that into a DataFrame that has two columns orig and dest that contain all of the unique combinations of orig and dest in df like this:

  orig   dest
1 ORD    LAX
2 AUS    JFK

so that I can iterate over each row and call a separate method that I've created for each orig and dest.

Is this possible? Most other answers that I've seen on here don't return a DataFrame object.

gr1zzly be4r
  • 2,072
  • 1
  • 18
  • 33

2 Answers2

2

You want to add below code to your code. It will give you dataframe with all unique rows. Please read this

df = df.drop_duplicates()
Rohan
  • 5,121
  • 1
  • 17
  • 19
1

You can do that with drop_duplicates éethod

print(df.drop_duplicates())
Diane Delallée
  • 123
  • 2
  • 9