Apr-12-2023, 07:57 PM
As mention bye buran so is it
So
set
,then there is one more surprise.>>> memory = {16, 8, 16, 64, 32} >>> memory {16, 8, 32, 64}Oops missing one valueđź‘€
So
list/tuple
would be more suited for this task,and to show an other way,Pandas do also like this kind of structure.import pandas as pd my_dict = { "Name": ["Kindle Fire", "Samsung Galaxy Tab", "Dell Streak", "Apple iPad", "Lenovo Tab"], "Memory": [16, 8, 16, 64, 32], "Processor": [2.2, 1.2, 1.8, 2.65, 2.3], "Cost": [199, 114.99, 59.99, 319, 129], } df = pd.DataFrame(my_dict)
>>> df Name Memory Processor Cost 0 Kindle Fire 16 2.20 199.00 1 Samsung Galaxy Tab 8 1.20 114.99 2 Dell Streak 16 1.80 59.99 3 Apple iPad 64 2.65 319.00 4 Lenovo Tab 32 2.30 129.00 >>> # Select the devices whose cost is over 150 using query >>> selected_devices = df.query('Cost > 150')['Name'] >>> selected_devices 0 Kindle Fire 3 Apple iPad Name: Name, dtype: object