s
represents self in the
apply
found here:
def background_gradient(s, m, M, cmap='RdBu'):
print type(s)
if M > -1*m:
max = M
else: max = -1*m
rng = max
norm = colors.Normalize(-2*max,
2*max)
normed = norm(s.values)
c = [colors.rgb2hex(x) for x in plt.cm.get_cmap(cmap)(normed)]
return ['background-color: %s' % color for color in c]
...
counts_table.style.applymap(color_negative_red)\
.apply(background_gradient,
cmap='RdBu',
m=df['Dataframe Value'].min().min(),
M=df['Dataframe Value'].max().max()
)\
.highlight_null(null_color='#F4F6F8')
I thought it may be a class of some sort. I've never had to create a class, but when I started playing with it, I couldn't seem to find a way that
print class
would give the desired outcome; at best I would need to use
print class.variable
but this leads to having to call each variable independently, where I need to be able to get them all at once. However you say the class has instances, which sounds different than nested objects.