You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
I was trying the above examples and it was not working this is the way it is working.
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':np.int32})
# this fails because it has dtype int64
df2 = pd.DataFrame({'A':[1,2,3]})
df2.pipe(ck.has_dtypes, items={'A':np.int64})
print(df1.dtypes)
print(df2.dtypes)
On Fri, Oct 4, 2019 at 4:34 AM abhijeet mote ***@***.***> wrote:
I was trying the above examples and it was not working this is the way it
is working.
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':np.int32})
# this fails because it has dtype int64
df2 = pd.DataFrame({'A':[1,2,3]})
df2.pipe(ck.has_dtypes, items={'A':np.int64})
print(df1.dtypes)
print(df2.dtypes)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#36?email_source=notifications&email_token=AAKAOIT5MJR4BZDH7VWM663QM4E33A5CNFSM4DNBZA52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALDJFA#issuecomment-538326164>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKAOIX6EG4PUMTSCXGEM3LQM4E33ANCNFSM4DNBZA5Q>
.
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
items
inhas_dtypes
can accept functions as values. This will allow us to use the functions inpandas.api.types
to 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.
The text was updated successfully, but these errors were encountered: