y.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.equals  #

DataFrame.  equals  (  _ other  _ )  [ [source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L1445-L1527) #

    

Test whether two objects contain the same elements.

This function allows two Series or DataFrames to be compared against each
other to see if they have the same shape and elements. NaNs in the same
location are considered equal.

The row/column index do not need to have the same type, as long as the values
are considered equal. Corresponding columns and index must be of the same
dtype.

Parameters  :

    

**other** Series or DataFrame

    

The other Series or DataFrame to be compared with the first.

Returns  :

    

bool

    

True if all elements are the same in both objects, False otherwise.

See also

[ ` Series.eq  ` ](pandas.Series.eq.html#pandas.Series.eq "pandas.Series.eq")

    

Compare two Series objects of the same length and return a Series where each
element is True if the element in each Series is equal, False otherwise.

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

    

Compare two DataFrame objects of the same shape and return a DataFrame where
each element is True if the respective element in each DataFrame is equal,
False otherwise.

[ ` testing.assert_series_equal  `
](pandas.testing.assert_series_equal.html#pandas.testing.assert_series_equal
"pandas.testing.assert_series_equal")

    

Raises an AssertionError if left and right are not equal. Provides an easy
interface to ignore inequality in dtypes, indexes and precision among others.

[ ` testing.assert_frame_equal  `
](pandas.testing.assert_frame_equal.html#pandas.testing.assert_frame_equal
"pandas.testing.assert_frame_equal")

    

Like assert_series_equal, but targets DataFrames.

[ ` numpy.array_equal  `
](https://numpy.org/doc/stable/reference/generated/numpy.array_equal.html#numpy.array_equal
"\(in NumPy v1.26\)")

    

Return True if two arrays have the same shape and elements, False otherwise.

Examples

    
    
    >>> df = pd.DataFrame({1: [10], 2: [20]})
    >>> df
        1   2
    0  10  20
    

DataFrames df and exactly_equal have the same types and values for their
elements and column labels, which will return True.

    
    
    >>> exactly_equal = pd.DataFrame({1: [10], 2: [20]})
    >>> exactly_equal
        1   2
    0  10  20
    >>> df.equals(exactly_equal)
    True
    

DataFrames df and different_column_type have the same element types and
values, but have different types for the column labels, which will still
return True.

    
    
    >>> different_column_type = pd.DataFrame({1.0: [10], 2.0: [20]})
    >>> different_column_type
       1.0  2.0
    0   10   20
    >>> df.equals(different_column_type)
    True
    

DataFrames df and different_data_type have different types for the same values
for their elements, and will return False even though their column labels are
the same values and types.

    
    
    >>> different_data_type = pd.DataFrame({1: [10.0], 2: [20.0]})
    >>> different_data_type
          1     2
    0  10.0  20.0
    >>> df.equals(different_data_type)
    False
    

[ __ previous  pandas.DataFrame.duplicated  ](pandas.DataFrame.duplicated.html
"previous page") [ next  pandas.DataFrame.filter  __
](pandas.DataFrame.filter.html "next page")

__ On this page

  * ` DataFrame.equals()  `

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

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

Created