Python Forum
Feature Scaling with Partitions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feature Scaling with Partitions
#2
Something like the following should work,

df['item_cnt_day'] = df.groupby('shop_id')['item_cnt_day'].transform(lambda x: (x-x.mean())/x.std())

However, if the group (a set of records with the same shop_id value) consist of one element only, this per-group scaling
will yield to NaN value (since x.std()= 0 if x is an array consisting of only one element).
Reply


Messages In This Thread
Feature Scaling with Partitions - by rocketfish - Aug-11-2020, 05:00 PM
RE: Feature Scaling with Partitions - by scidam - Aug-12-2020, 01:06 AM
RE: Feature Scaling with Partitions - by rocketfish - Aug-12-2020, 12:27 PM
RE: Feature Scaling with Partitions - by rocketfish - Aug-13-2020, 01:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scaling of mapped vectors? sricha1217 1 2,413 Apr-10-2018, 10:26 AM
Last Post: sricha1217

Forum Jump:

User Panel Messages

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