Error in numpy

plt.scatter(your_df.CocoaPercentage, your_df.Rating)

z = np.polyfit(your_df.CocoaPercentage, your_df.Rating, 1)
line_function = np.poly1d(z)
plt.plot(your_df.CocoaPercentage, line_function(your_df.CocoaPercentage), “r–”)

its showing an error like
File “/usr/local/lib/python3.6/dist-packages/numpy/lib/”, line 592, in polyfit
x = NX.asarray(x) + 0.0
TypeError: must be str, not float
how to fix it

Hello, @ajaysingh5109027536, and welcome to the Codecademy Forums!

It is useful for your posts to include a link to the Codecademy content on which you are working, so that users can find the instructions and their own version of the code, for comparison with yours.

Link to project: Chocolate Scraping with Beautiful Soup

We will need to see more of your code in order to find the problem. Please remember to format any code that you post, so that we can see important details, such as indentation and underscores. See How to ask good questions (and get good answers) for advice on how to format code for posting.

1 Like

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.