I have a Pandas Dataframe and I want to return a value (or a function) if a specific value is found in the DataFrame.
I have looked everywhere and all I could mostly find is if the value is found, then it will return either True or False. And most of the search results pointed to similar answers.
The True or False is helpful to go in the right direction, but what I want to ultimately do would be something like
if a.values == 'abc':
function()
or something like
if a.values == 'abc':
plt.imgplot(a.png)
CodePudding user response:
You could use a for loop and check for your condition:
df = pd.DataFrame({'a':[1,2,3],'b':[1,2,3]})
for val in df.values:
if val == 1:
plt.imgplot(df)
