Having most storage space?

Screen Link:
https://app.dataquest.io/m/293/data-cleaning-basics/13/next-steps

How to find the laptop with the most storage capacity?

Hi,

What you have to do is to get rid of letters ( one way or the other). I used df.str.extract(’(\d+)’).astype(float) . Then you have to distinguish TB from GB. My approach was to rid off all numbers greater than 64 ( because the smallest driver those days has 64GB. If something is smaller it points to TB drive space). My full answer for this question is:


# 3. Which laptop has the most storage space?

# Building def for removing prefix:
clean_storage = (laptops[laptops['storage']
                         .str.extract('(\d+)').astype(float) < 64]
                )# "< 64" allows to filter just TB storages

clean_storage_max = laptops[laptops["storage"] == clean_storage['storage'].max()]
clean_storage_max_the_one = clean_storage_max.iloc[0]
print('\n')
print('Answer 3:')
print('\n')
print(clean_storage_max_the_one['manufacturer':'model_name'])
print(clean_storage_max_the_one['storage'])

output:
image
Variables: