Today is is a bit difficult to check on pandas dtypes directly. For example see below:
import numpy as np
import pandas as pd
import engarde.checks as ck
# this works because it has dtype int32
df1 = pd.DataFrame({'A':[1,2,3]}, dtype=np.int32)
df1.pipe(ck.has_dtypes, items={'A':int})
# this fails because it has dtype int64
df2 = pd.DataFrame({'A':[1,2,3]})
df2.pipe(ck.has_dtypes, items={'A':int})
To make dtype-checking more robust, I propose that the parameter items in has_dtypes can accept functions as values. This will allow us to use the functions in pandas.api.types to check dtypes which will ease dtype. checking
For example:
df2 = pd.DataFrame({'A':[1,2,3]})
df2.pipe(ck.has_dtypes, items={'A':pd.api.types.is_integer_dtype})
I have already written a proposal on this (but it needs tests). I will just push it straight away so for your review.
Today is is a bit difficult to check on pandas dtypes directly. For example see below:
To make dtype-checking more robust, I propose that the parameter
itemsinhas_dtypescan accept functions as values. This will allow us to use the functions inpandas.api.typesto check dtypes which will ease dtype. checkingFor example:
I have already written a proposal on this (but it needs tests). I will just push it straight away so for your review.