It seems the code below doesn't work
i = int(f)
Why should it? A Line is a continuous series of values which grows over time. Which of the values are you expecting to convert?