I am trying to convert elements at index[2] to int type using this func that I wrote. The data in the csv file looks like this
`
id neighbourhood_group room_type price
2539 Brooklyn Private room 149
2595 Manhattan Entire home/apt 225
3647 Manhattan Private room 150
`
def load_dt():
with open(filename) as f:
# skip the header
next(f, None)
# line[1:] skip first column
data = [tuple(line[1:]) for line in csv.reader(f)]
return data
The output of the code:
[('Manhattan', 'Shared room', '55'), ('Manhattan', 'Private room', '90')]
What I need is that index[2] = type int and maintaining the same data structure because my previous work built on the same data structure list of tupes