.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ DataFrame ](../frame.html)
  * pandas.DataF... 

#  pandas.DataFrame.__add__  #

DataFrame.  __add__  (  _ other  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/arraylike.py#L98-L186) #

    

Get Addition of DataFrame and other, column-wise.

Equivalent to ` DataFrame.add(other)  ` .

Parameters  :

    

**other** scalar, sequence, Series, dict or DataFrame

    

Object to be added to the DataFrame.

Returns  :

    

DataFrame

    

The result of adding ` other  ` to DataFrame.

See also

[ ` DataFrame.add  ` ](pandas.DataFrame.add.html#pandas.DataFrame.add
"pandas.DataFrame.add")

    

Add a DataFrame and another object, with option for index- or column-oriented
addition.

Examples

    
    
    >>> df = pd.DataFrame({'height': [1.5, 2.6], 'weight': [500, 800]},
    ...                   index=['elk', 'moose'])
    >>> df
           height  weight
    elk       1.5     500
    moose     2.6     800
    

Adding a scalar affects all rows and columns.

    
    
    >>> df[['height', 'weight']] + 1.5
           height  weight
    elk       3.0   501.5
    moose     4.1   801.5
    

Each element of a list is added to a column of the DataFrame, in order.

    
    
    >>> df[['height', 'weight']] + [0.5, 1.5]
           height  weight
    elk       2.0   501.5
    moose     3.1   801.5
    

Keys of a dictionary are aligned to the DataFrame, based on column names; each
value in the dictionary is added to the corresponding column.

    
    
    >>> df[['height', 'weight']] + {'height': 0.5, 'weight': 1.5}
           height  weight
    elk       2.0   501.5
    moose     3.1   801.5
    

When  other  is a [ ` Series  ` ](pandas.Series.html#pandas.Series
"pandas.Series") , the index of  other  is aligned with the columns of the
DataFrame.

    
    
    >>> s1 = pd.Series([0.5, 1.5], index=['weight', 'height'])
    >>> df[['height', 'weight']] + s1
           height  weight
    elk       3.0   500.5
    moose     4.1   800.5
    

Even when the index of  other  is the same as the index of the DataFrame, the
[ ` Series  ` ](pandas.Series.html#pandas.Series "pandas.Series") will not be
reoriented. If index-wise alignment is desired, [ ` DataFrame.add()  `
](pandas.DataFrame.add.html#pandas.DataFrame.add "pandas.DataFrame.add")
should be used with  axis=âindexâ  .

    
    
    >>> s2 = pd.Series([0.5, 1.5], index=['elk', 'moose'])
    >>> df[['height', 'weight']] + s2
           elk  height  moose  weight
    elk    NaN     NaN    NaN     NaN
    moose  NaN     NaN    NaN     NaN
    
    
    
    >>> df[['height', 'weight']].add(s2, axis='index')
           height  weight
    elk       2.0   500.5
    moose     4.1   801.5
    

When  other  is a [ ` DataFrame  ` ](pandas.DataFrame.html#pandas.DataFrame
"pandas.DataFrame") , both columns names and the index are aligned.

    
    
    >>> other = pd.DataFrame({'height': [0.2, 0.4, 0.6]},
    ...                      index=['elk', 'moose', 'deer'])
    >>> df[['height', 'weight']] + other
           height  weight
    deer      NaN     NaN
    elk       1.7     NaN
    moose     3.0     NaN
    

[ __ previous  pandas.DataFrame.query  ](pandas.DataFrame.query.html "previous
page") [ next  pandas.DataFrame.add  __ ](pandas.DataFrame.add.html "next
page")

__ On this page

  * ` DataFrame.__add__()  `

[ __ Show Source
](../../_sources/reference/api/pandas.DataFrame.__add__.rst.txt)

© 2024, pandas via [ NumFOCUS, Inc. ](https://numfocus.org) Hosted by [
OVHcloud ](https://www.ovhcloud.com) .

Created using [ Sphinx ](https://www.sphinx-doc.org/) 7.2.6.  

Built with the [ PyData Sphinx Theme ](h