-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
valid parameters check while reading data #22189
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
I thought we had another issue for this (#17994 was aobut |
The most difficult part is that kwds is passed through to the underlying engine. We would want to reconcile the common keyword arguments, and then perhaps provide an |
That thread ends with your note "the goal is to remove the |
Yes, that issue was specifically for sheetname.
I'm not sure why a decorator would be useful, could you explain?
…On Fri, Aug 3, 2018 at 8:54 AM Shantanu Oak ***@***.***> wrote:
That thread ends with your note "the goal is to remove the **kwargs from
the signature". And the issue is closed! May be a decorator should be
considered.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#22189 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHImYCI1JJcEPUNIlQ3wDOs5DYByaNks5uNFYNgaJpZM4Vt6-x>
.
|
I just saw a decorator called "deprecate_kwarg" to deprecate a keyword argument of a function. I thought similar concept can be used for "validate_kwarg". Ignore this comment if that is not the case. |
May be this function in pandas/pandas/util/_decorators.py
and a decorater added in the file pandas/io/excel.py @validate_kwarg() |
I don't think a decorator is necessary here, since this is only being
applied to a single function.
I think the best path forward is to remove the need for **kwargs in
read_excel.
…On Fri, Aug 3, 2018 at 3:01 PM Shantanu Oak ***@***.***> wrote:
May be this function
def validate_kwarg():
def _validate_kwarg(func):
@wraps(func)
def wrapper(*args, **kwargs):
expected_keys=['io', 'sheet_name','header', 'names', 'index_col', 'usecols', 'squeeze', 'dtype', 'engine',
'converters', 'true_values', 'false_values', 'skiprows', 'nrows', 'na_values', 'verbose', 'parse_dates',
'date_parser', 'thousands', 'comment', 'skipfooter', 'convert_float']
if set(kwargs.keys()).difference(set(expected_keys)):
raise ValueError('invalid parameter found')
return func(*args, **kwargs)
return wrapper
return _validate_kwarg
and a decorater added in the file pandas/io/excel.py
@validate_kwarg()
@appender(_read_excel_doc)
@deprecate_kwarg("parse_cols", "usecols")
@deprecate_kwarg("skip_footer", "skipfooter")
def read_excel(io,
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#22189 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIkYJTJmBk5RfO4VVkAP4Q7jYPIGlks5uNKwQgaJpZM4Vt6-x>
.
|
https://pandas.pydata.org/pandas-docs/dev/whatsnew/v1.3.0.html#other-api-changes Closing, but happy to reopen if there is more to this issue |
Pandas seems to ignore the extra (invalid) parameters. For e.g.
Code Sample, a copy-pastable example if possible
Note that some_dummy_param does not throw an error.
Problem description
Is there any way to make sure only valid parameters are passed to read_excel method?
Expected Output
Since there is no such parameter called "some_dummy_param", I should get an error:
The text was updated successfully, but these errors were encountered: