Created
February 23, 2021 14:52
-
-
Save pbeens/fa08304a7575cf51314f64d6496d8228 to your computer and use it in GitHub Desktop.
Lighthouse Labs 21 Day Data Challenge 2021 #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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