str.isalpha() is used to check if all characters on each line, the series are alphabetic (az / AZ). Space or any other character occurrence in the string will return false, but if there is a full numeric value, then NaN will be returned.
Syntax: Series.str.isalpha () p>
Return Type: Boolean series, Null values might be included too depending upon caller series.
To load the CSV used in the code, click here.
In the following examples, the data frame used contains data for some NBA players. An image of the data frame before any operations is attached below.
Example # 1:
In this example the isalpha () method is applied to the College column. Before that, null lines are removed using the .dropna () method to avoid errors.
As shown in the output image, bool_series can be matched against the College column and you can clearly see that if the string contains alphabets only, True is returned.
Example # 2:
In this example the isalpha () method is applied to the Name column twice. First, a bool series is created for the original name column, and then the spaces are removed using the str.replace (), and then a new bool_series is created again.
As shown in the output image, the Bool series was false for all values as long as the lines had no spaces. After removing spaces in the string, bool is only specified false if there are special characters in the string.
If you can program, you are ready to grapple with Bayesian statistics. In this book, you'll learn how to solve statistical problems using Python code instead of math formulas, using discrete probabili...
This book introduces machine learning methods in finance. It features a unified treatment of machine learn...
This book project was first presented to me during my first week in my current role of managing the data mining development at SAS. Writ- ing a book has always been a bucket‐list item, and I was ver...
Learning to code is tremendous fun as you can get instant results, no matter how much more you have to learn. In fact, it’s such fun creating games and programs that it feels effortless once you’r...