Search
[python] AttributeError: 'Series' object has no attribute 'find'
- M.R

- Aug 18, 2021
- 1 min read
Situation
The above error occurs when trying to plot the data stored in the DataFrame of pandas.
Cause
The data type was object. The content of the data is a numerical value, but probably because of the way of writing in the csv file, it was an object type when it was read into the DataFrame. Let's check first ...
Solution
You can check the data type in DataFrame.dtypes.
x=np.random.randint(0, 3, 100)
y=[str(i) for i in x]
df=pd.DataFrame({'x': x, 'y':y})
df.dtypesx int32
y object
dtype: objectData type conversion can be done with the astype () method.
df['y']=df['y'].astype('int')
df['y'].dtypedtype('int32')





Comments