Hands on pandas.Series in Python
pandas.Series.str¶
The attribute
pandas.Series.str
can only be used with Series ofstr
values. You will either encounter anAttributionError
(Can only use .str accessor with string values, which use np.object_ dtype in pandas) or find it to yield a Series ofNaN
's if you invoke it on a Series of non-string values. If you have control of the DataFrame, the preferred way is to cast the type the column tostr