I would like to use some sort of if conditions to Plot only if the value of a specific column reaches a certain value.
Let's say in the example below I would like to plot only if the value of the cycle == 2.
import pandas as pd
import matplotlib.pyplot as plt
data = [('cycle',[1,1,2,2,3,3,4,4]),
('A',[0.1,0.5,0.2,0.6,0.15,0.43,0.13,0.59]),
('B',[ 500, 600, 510,580,512,575,499,598]),
]
df = pd.DataFrame.from_items(data)
#print(df)
x = df['A']
y = df['B']
if df['cycle']==2:
plt.plot(x,y)
if I trie this, I got the fowlling error: ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Until now, I had no luck finding a way to solve the problem.
I am thankful for any help in regard to this Problem. Have a very nice day.