Skip to content

Commit e5e82a2

Browse files
added wrapper class for pandas dataframes to enable equality comparisons
1 parent 9c96115 commit e5e82a2

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class DfWrap:
2+
"""
3+
A wrapper class for a pandas DataFrame that provides custom functionality,
4+
such as comparing equality with another DataFrame.
5+
"""
6+
7+
def __init__(self, df):
8+
"""
9+
Initializes the DfWrap instance with a pandas DataFrame.
10+
11+
Parameters:
12+
df (pd.DataFrame): The DataFrame to wrap.
13+
"""
14+
self.df = df
15+
16+
def __eq__(self, df2):
17+
"""
18+
Checks if the wrapped DataFrame is equal to another DataFrame.
19+
20+
Parameters:
21+
df2 (pd.DataFrame): The DataFrame to compare with the wrapped DataFrame.
22+
23+
Returns:
24+
bool: True if the two DataFrames are equal, False otherwise.
25+
"""
26+
return all(self.df == df2)

0 commit comments

Comments
 (0)