I have two pandas dataframes: One assembled manually in Python, the other imported from a dashboard's .csv output.
All columns in both dataframes are objects, and look like this:
| 2020 | 2021 | 2022 | 2023 |
|---|---|---|---|
| 0.441 | 0.554 | 0.113 | 0.445 |
| 0.233 | 0.215 | 0.225 | 0.115 |
| Fifty (50/99) | One (1/99) | Ten (10/99) | Eleven (11/99) |
| 0.554 | 0.111 | 0.545 | 0.577 |
| Africa | Europe | Africa | Asia |
y_2020 = [0.441, 0.233, 'Fifty (50/99)', 0.554, 'Africa']
y_2021 = [0.554, 0.215, 'One (1/99)', 0.111, 'Europe']
y_2022 = [0.113, 0.225, 'Ten (10/99)', 0.545, 'Africa']
y_2023 = [0.445, 0.115, 'Eleven (11/99)', 0.577, 'Asia']
df1 = pd.DataFrame(
data = list(zip(y_2020, y_2021 , y_2022, y_2023)),
columns = ['2020', '2021', '2022', '2023'])
df2 = df1.copy()
I want to check if the dashboard is producing accurate figures by comparing the contents of both outputs. I'd like to check the numeric values are within a 0.1 tolerance of each other. Strings must be exact.
I'm struggling with .equals() and .compare() because of the string/integer mix and wanting a 0.1 tolerance.
Thanks.
for-loop to check every value in row. And if every row has different data then you could create different code for different data.abs()and compare it with<= 0.1