-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Option to Raise Exception on Unmapped Value in Series.map #14210
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 am not sure what the intent / meaning of this parameter. @cancan101 can you give an example? |
If I were do this: Series(['a', 'b']).map({'a': 1, 'b': 3}) my return type is of Series(['a', 'b ']).map({'a': 1, 'b': 3}) # note space my return type is I could assert that the type is int (brittle and just works for ints) or perhaps check all of the unique values in advance to make sure they are a subset of the mapping |
Related (but different from) #13473 I'd be in favor of adding a Does anyone know what the |
Quite the 6-year necroraise, but little bump that would be really useful to have an A workaround for the moment is to (re)define class WillRaise(dict):
def __missing__(self, key):
raise KeyError(key)
mapping = WillRaise({"Foo": 1})
pd.Series(["Foo", "Bar"]).map(mapping) # KeyError: 'Bar' |
Hi all, |
bump to this! would love a raise na_option |
Hey guys, I prepared a PR in #60482, please review if the functionality and docs are understandable! |
Add a flag (or extend
na_action
) to raise an exception inSeries.map
if a value is not successfully mapped (ie in the case wherearg
is a dict.The text was updated successfully, but these errors were encountered: