My problem is quite difficult to explain and I'm unsure if it's even possible to do what I'm asking, but I will try my best to explain.
Basically, I have a CSV file with data, and I want to extract specific cells and set them as a value in an object. Each row in the CSV contains information about an individual item. Currently, I have it hard coded using the pandas library and by doing df.iloc[0][1], etc. However, I want to be able to loop through the whole CSV and extract individual cells and add them to multiple objects, so I don't have to hard code every row manually.
Hopefully, the code will help show what I mean:
df = pd.read_csv('Options.csv')
My Class:
class Option:
def __init__(self, type, name, S, K):
self.type = type
self.name = name
self.S = S
self.K = K
Current Extraction from CSV:
o1 = Option(df.iloc[0, 1], df.iloc[0][2], df.iloc[0][3], df.iloc[0][4])
o2 = Option(df.iloc[1, 1], df.iloc[1][2], df.iloc[1][3], df.iloc[1][4])
etc.
I still want to be able to select individual values of each option, for example, print(o1.name), o6.type, etc.