-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Closed
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action
Description
Hi,
I would like to map a function expecting N arguments to a DataFrame of N columns. Today to do that I do:
df = pd.DataFrame({"A": [1, 2, 3, 4], "B": [5, 6, 7, 8]})
def f(x,y):
return x*y
df[['A', 'B']].apply(lambda x: f(*x), axis=1)
So the map
method for DataFrame would be:
def map(self, f):
return self.apply(lambda x: f(*x), axis=1)
if I am right. Then df.map(f)
would produce a Serie.
Note that with 1 colummn and a 1 argument function map
would work as numpy.map
does.
Thanks,
Olivier.
ps: I edited this post after the talk I had with Tom, so it must seem strange now 😃
Metadata
Metadata
Assignees
Labels
EnhancementNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further action