HI I need to test and validate the columns from an excel file with Pandas and Pytest
Here is my code
import pytest
import pandas as pd
import datatest as dt
@pytest.fixture(scope='module')
def df():
if os.path.exists(f"test_data/example_pricing.xlsx"):
with open(f"test_data/example_pricing.xlsx", "rb") as f:
excel_data_df = pd.read_excel(f"test_data/example_pricing.xlsx", sheet_name='CustomerPricing',
usecols=lambda c: not c.startswith('Unnamed:'))
return excel_data_df
@pytest.mark,mandatory
def test_columns(df):
dt.validate(df.columns,{'Age'},) # Age here is a column in excel file
But I got validationError, unable to pass the test
FAILED tests/unit/tests.py::test_columns - datatest.ValidationError: does not satisfy set membership (18 differences): [
Any ideas how to validate columns from excel using pandas ?