I have data in the following CSV file, available here:
http://s000.tinyupload.com/index.php?file_id=87473936848618674050
Screenshot of the CSV:
I've written the following code to import the CSV file into Python as a Pandas Dataframe, and then the code after that creates a dictionary dict
. The dictionary has to have name and region as the keys, and the Windows and Linux prices as the dictionary values.
#Import libraries and CSV file into dataframe, renaming columns, printing head
import pandas as pd
df = pd.read_csv('file.csv')
col_names = ['Name','Region','API', 'Memory','vCPU', 'Storage', 'Linux', 'Windows' ]
df.columns = col_names
#Creating Dict
dict = {}
for i in df.index:
key = (df.at[i, 'Name'] , df.at[i, 'Region'])
value = (df.at[i, 'vCPU'], df.at[i, 'Memory'], df.at[i, 'Storage'], df.at[i, 'Windows'] , df.at[i, 'Linux'])
dictionary = {key:value}
dict.update(dictionary)
I now would like to write a function that would allows me to search through the dictionary.
For example, the user would input "32" for vCPUs, the function would bring back the region, name and Linux and Windows prices for any processors that have 32 vCPUs.
Later, I want to implement this search function for vCPU, Memory and Storage. (the full CSV has 1700 rows). Would really appreciate someone helping me out.