-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels