Soulofknight
Soulofknight

Reputation: 11

This set of code keep on looping and looping. May I know how to stop looping?

I am using this code to plot one column by column graph and it works. However I am having a problem. The window of the first column graph plot came out, and when I close it, the second column graph plot came out next. Once I close it, once again, the first column graph plot came out again, close it then second come out, close it then first one again. It keeps going through this continuous loop non stop. Does anyone knows how to stop this loop? Is there any error on my code?

file_path = ("C://Users/RichardStone/Pycharm/Project/train_data.csv")

df = pd.read_csv(file_path)

for column in df.columns:

print(df.iloc[:, [1]])

plt.figure('Train data: Jitter (Local)')

plt.title('Feature: Jitter (Local)')

plt.plot(df.iloc[:, [1]])

plt.show()

print(df.iloc[:, [2]])

plt.figure('Train data: Jitter (local, absolute)')

plt.title('Feature: Jitter (local, absolute)')

plt.plot(df.iloc[:, [2]])

plt.show()

Upvotes: 0

Views: 25

Answers (1)

Wrench
Wrench

Reputation: 491

Well your graph plotting is inside the for loop.This is why it is keep showing graph for times your data length is. Once data is read by script, Indent back and then show the graph

Upvotes: 0

Related Questions