Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
An Object of Objects?
#3
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.
Reply


Messages In This Thread
An Object of Objects? - by cebb - Jul-27-2019, 12:42 PM
RE: An Object of Objects? - by mcmxl22 - Jul-27-2019, 05:48 PM
RE: An Object of Objects? - by cebb - Jul-27-2019, 06:41 PM
RE: An Object of Objects? - by cebb - Jul-28-2019, 02:50 AM
RE: An Object of Objects? - by cebb - Jul-28-2019, 03:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a library for recursive object creation using config objects johsmi96 0 1,871 May-03-2021, 08:09 PM
Last Post: johsmi96
  Player object wont recognize collision with other objects. Jan_97 3 2,757 Dec-22-2019, 04:08 PM
Last Post: joe_momma
  How to redefine object so that all user- objects have the necessary capabilities? AlekseyPython 5 3,093 Mar-03-2019, 04:25 AM
Last Post: AlekseyPython
  error creating new object after loading pickled objects from file arogers 2 3,493 Feb-02-2019, 10:43 AM
Last Post: Larz60+
  AttributeError: 'NoneType' object has no attribute 'n' in list of class objects jdrp 4 5,793 Jun-19-2018, 02:44 PM
Last Post: jdrp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020