Question: I want to plot line graph row my row & I want the previous line to be updated by the next line (on the same frame).
Here's the example of the input:

[![enter image description here](https://i.stack.imgur.com/OnJJS.png)](https://i.stack.imgur.com/OnJJS.png)

Here's the code that I have:

```
def openB():
bmFile = filedialog.askopenfile(mode='r',
                                    filetypes=(("CSV file", "*.csv"), ("All files", "*.*")),
                                    title="Select a CSV file")

bmFile2 = pd.read_csv(bmFile, header=[2])

selectCol = bmFile2.iloc[0:,3:]

selectCol.T.plot()
plt.show()

```

I want to plot each row, that's why I am using Transpose method on selectCol.

In order to plot row by row (dynamically changing), what function should I do?
FuncAnimation or for loop (range)?
and How?

Thank you.
Greatly appreciated :)

Answer: 
It's running, but just the time it takes is huge.
You can check by the following code, it keeps going to print `x`'s.

```python
n = 600851475143
x = 0
for i in range(2, n):
    if n % i == 0:
        if x < i:
            x = i
            print(x)

```

---

To save time, you can try the following code instead of your code:

```python
n = 600851475143
x = 0
for i in range(2, n):
    if n % i == 0:
        x = n // i
        break
print(x) 

```

which prints `8462696833` instantly. But as @seesharper stated on the comment, it is merely the largest factor and not a *prime* factor. So it is not the correct answer to the [Project Euler Problem #3](https://projecteuler.net/problem=3).
Check this code you will save a lot of time

Using `sqrt` for optimization

```
from math import sqrt
def Euler3(n):
    x=int(sqrt(n))
    for i in range(2,x+1):
        while n % i == 0:
            n //= i
            if n == 1 or n == i:
                return i
    return n
n = int(input())
print(Euler3(n))

```

---

Also, check my [Euler git repo](https://github.com/7u5h4r/ProjectEuler)

There are only 6 solutions in python2 and it's pretty old but they are very well optimized.