Skip to content

Instantly share code, notes, and snippets.

@pbeens
Created February 23, 2021 14:52
Show Gist options
  • Save pbeens/fa08304a7575cf51314f64d6496d8228 to your computer and use it in GitHub Desktop.
Save pbeens/fa08304a7575cf51314f64d6496d8228 to your computer and use it in GitHub Desktop.
Lighthouse Labs 21 Day Data Challenge 2021 #7
# Sort the boxes by weight
# https://data-challenge.lighthouselabs.ca/challenge/7
import pandas as pd
user_boxes = {'weight': [4,2,18,21,14,13],
'box_name': ['box1','box2', 'box3', 'box4', 'box5', 'box6']
}
def boxes_sorted_by_weight(b):
df = pd.DataFrame(b)
df.sort_values(by=['weight'], inplace=True)
boxes = []
for item in df.box_name:
boxes.append(item)
return(boxes)
print(boxes_sorted_by_weight(user_boxes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment