Ben Chuanlong Du's Blog

It is never too late to learn.

Hands on pandas.Series in Python

pandas.Series.str

  1. The attribute pandas.Series.str can only be used with Series of str values. You will either encounter an AttributionError (Can only use .str accessor with string values, which use np.object_ dtype in pandas) or find it to yield a Series of NaN'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 to str