Open ujex256 opened 5 months ago
Can a contributor look into this and if needed I will work on the PR :P unless @ujex256 or someone else is already working on it.
@krishsharma0413 Thank you for your help! I was already trying to get the PR out. I appreciate your concern.
@ujex256 The pd.Series.str
accessor in pandas does not have an isascii
method by default. However, you can achieve the desired functionality by using a custom function combined with the apply
method.
import pandas as pd
def is_ascii(s):
return all(ord(c) < 128 for c in s)
series = pd.Series(["a", "b", "c", "あ", ""])
series_isascii = series.apply(is_ascii)
print(series_isascii)
"""
0 True
1 True
2 True
3 False
4 True
dtype: bool
"""
let me know, if it works Thanks
I think this is more of a Feature Request rather than a bug.
A temporary workaround could be series.apply(lambda x: x.isascii())
.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
pd.Series.str does not support
isascii()
metod.Expected Behavior
The code shown above would look like this.
Installed Versions