-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
inplace kwarg must be of bool type, but other boolean kwargs don't have this restriction #16714
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
Comments
Perhaps when checking in |
We should fix all boolean input arguments with this check. We have in effect some strict type checking. @colinmorris if you read the other issue, the problem is this can easily be from user error, where they are passing args and not as keyword arguments. So its nice if pandas can fail fast with an obvious error. PR's to validate boolean input args welcomed! |
I'll start working on this. Just a quick question, do I have to validate boolean input args just for the set_index function or also for every function with boolean kwargs? |
ideally we should do this for all function args that are boolean start with a certain class of them e.g. like inplace (though these are mostly done i think) |
@TomAugspurger [Scipy2017 Sprint] I decided the route to take is to type check using |
@pambot : That's going to be a little laborious, but if you can do that, (at least for some chunk of them), then go right ahead! |
take |
If it is still open then I would be interested to work on this. |
@Condielj @jreback @colinmorris is this issue still unresolved? I'm interested in picking it up as my first contribution to pandas. If it is unresolved, do we have a list of args that should require boolean type checking? Is it just |
Just checked that the issue still exists with latest dev version of pandas (3.0.0). |
take |
Hello @gfyoung, @jreback, @mroeschke, @jbrockmendel and team! I looked into this issue and looks like we need to validate the bool kwargs for all the methods in dataframe and series object methods (please correct me if I am wrong). |
Code Sample, a copy-pastable example if possible
Using
DataFrame.set_index
as an example, but this applies to other methods that take an inplace kwarg:The last line raises
ValueError: For argument "inplace" expected type bool, received type int.1
Problem description
This behaviour seems inconsistent.
Expected Output
The last line should proceed successfully with inplace treated as
True
.Or every boolean kwarg should be type-checked, though I like this option much less. I think using 0/1 as shorthand for True/False is a pretty common idiom.
It looks like this is the result of a somewhat recent 'bug fix': #14189. To me, it feels like a regression.
Output of
pd.show_versions()
pandas: 0.20.1
pytest: None
pip: 9.0.1
setuptools: 36.0.1
Cython: None
numpy: 1.12.1
scipy: 0.19.0
xarray: None
IPython: 5.4.1
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: