Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsDtypeValidation not accepting multiple dtypes for a DataFrame Column #61

Open
pranshuag9 opened this issue Jul 27, 2021 · 5 comments
Open
Labels

Comments

@pranshuag9
Copy link
Contributor

pranshuag9 commented Jul 27, 2021

I am trying to input int or float, in parameter dtype of IsDtypeValidation but it doesn't accept multiple types. As a general type, i tried with numbers.Number which is a general class for all numbers but it throws error: "The column column_name has a dtype of int64 which is not a subclass of the required type <class 'numbers.Number'>".

Similar error comes when i have assigned it to np.dtype(float) and values in column are only integer.
Same for np.dtype('d'), np.dtype(np.inexact) n all.

I tried using np.inexact or numbers.Number because i thought np.issubdtype() would accept it as True. Is it so?

How can i take multiple dtypes in a column and validate it to True? like it can be float if value in column is float, it can be integer, if value is integer.

@multimeric
Copy link
Owner

Hmm this is a bug if it's exhibiting this behaviour. Can you post a reproducible example where a sub dtype isn't validating correctly?

@pranshuag9
Copy link
Contributor Author

pranshuag9 commented Jul 27, 2021

thanks for quick reply. I tried again with dtype=np.number and it worked. since internally np.number is accepted by np.issubdtype(). There is another issue now. I see yellow warning(in PyCharm IDE) in dtype=np.number in IsDtypeValidation(), as variable annotation for dtype is specialized only to np.dtype which should be generalized to some super type.

@multimeric
Copy link
Owner

Can you show me the warning message?

@pranshuag9
Copy link
Contributor Author

pranshuag9 commented Jul 28, 2021

yes

image
image

This warning message is coming because dtype is specialized only to np.dtype here
image

For a temporary fix, it can be Union[np.dtype, np.number], but i think there can be a generalized solution.

@multimeric
Copy link
Owner

Okay so it's a bug with the type annotation. I just need to find out what type annotation is used internally by numpy/pandas and use the same one, or else have a Union as you suggest.

@multimeric multimeric added the bug label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants