top of page

[python] AttributeError: 'Series' object has no attribute 'find'


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.dtypes
x     int32
y    object
dtype: object

Data type conversion can be done with the astype () method.

df['y']=df['y'].astype('int')
df['y'].dtype
dtype('int32')

Recent Posts

See All

[Python] Output pandas.DataFrame as json

Summary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in pandas.DataFrame format. I want to output this result to a file in j

[Python] Conditionally fitting

Overview If you want to do fitting, you can do it with scipy.optimize.leastsq etc. in python. However, when doing fitting, there are many cases where you want to condition the fitting parameters. For

Comments


Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page