shanmuga
shanmuga

Reputation: 4499

Where to find the source code for pandas DataFrame __add__

I am trying to understand what (how) happens when two pandas.DataFrames are added/subtracted.

import pandas as pd
df1 = pd.DataFrame([[1,2], [3,4]])
df2 = pd.DataFrame([[11,12], [13,14]])

df1 + df2     # Which function is called?

My understanding is __add__ function should be implemented in a class to overload + operator, but in the source code for pandas.core.frame.DataFrame and all its parent classes no such function is found.

Where should I look for the function which is doing this job?

Upvotes: 2

Views: 2848

Answers (1)

jezrael
jezrael

Reputation: 863166

I think you need check this:

def add_special_arithmetic_methods(cls, arith_method=None,
                                   comp_method=None, bool_method=None,
                                   use_numexpr=True, force=False, select=None,
                                   exclude=None, have_divmod=False):
...
...

Upvotes: 2

Related Questions