Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({1: [20], 2: [30]})
df
Out[2]:
1 2
0 20 30

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

In [3]:
exactly_equal = pd.DataFrame({1: [20], 2: [30]})
exactly_equal
Out[3]:
1 2
0 20 30

Pandas: DataFrame - df and exactly_equalk have the same types and values for their elements and column lebel.

In [4]:
df.equals(exactly_equal)
Out[4]:
True

Pandas: DataFrame - df and exactly_equal have the same types and values for their elements and column lebel, which will return 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:

In [5]:
different_column_type = pd.DataFrame({1.0: [20], 2.0: [30]})
different_column_type
Out[5]:
1.0 2.0
0 20 30
In [6]:
df.equals(different_column_type)
Out[6]:
True

Pandas: DataFrame - df and different_column_type have the same element types and values but have different types for the column lebel, which will return 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:

In [7]:
different_data_type = pd.DataFrame({1: [20.0], 2: [30.0]})
different_data_type
Out[7]:
1 2
0 20.0 30.0
In [8]:
df.equals(different_data_type)
Out[8]:
False

Pandas: DataFrame - df and different_data_type have the different types for the same values for their elements, and will return False even though their column lebels are the samek values and types, False.