I have alot of data in a dictionary format and I am attempting to use pandas print a string based on an IF ELSE statement. For my example ill make up some data in dict and covert to Pandas:
df = pd.DataFrame(dict(a=[1.5,2.8,9.3],b=[7.2,3.3,4.9],c=[13.1,4.9,15.9],d=[1.1,1.9,2.9]))
a b c d
0 1.5 7.2 13.1 1.1
1 2.8 3.3 4.9 1.9
2 9.3 4.9 15.9 2.9
My IF ELSE statement:
for col in df.columns:
if (df[col] < 4).any():
print('Zone %s does not make setpoint' % col)
print('Zone %s is Normal' % col)
Zone a does not make setpoint
Zone b does not make setpoint
Zone c is Normal
Zone d does not make setpoint
But now I want to add in an extra to create a box plot where I am not making setpoint and also average the data frame where it is making setpoint. I know this is pandas series, but can pandas.Series.plot.box() be used?
This is my IF ELSE statement that I am using in a function with df.apply(lamba x:) and I am stuck trying to get the box box plot to work in pandas series... Any advice is greatly appreciated!
import matplotlib.pyplot as plt
if (x < 4).any():
print('Zone %s does not make setpoint' % x.name)
print('Zone %s is Normal' % x.name)
print('The average is %s' % x.mean())
Im getting an error when I am calling df.apply(lambda x: _print(x))
module 'matplotlib' has no attribute 'show'