mrdbourke / zero-to-mastery-ml

All course materials for the Zero to Mastery Machine Learning and Data Science course.
https://dbourke.link/ZTMmlcourse
2.97k stars 3.44k forks source link

Pandas Exercises Solution #67

Open devpatel2103 opened 1 year ago

devpatel2103 commented 1 year ago

In[24]

This does not work anymore car_sales.groupby(["Make"]).mean()

The mean now needs a condition in order for it to work car_sales.groupby(["Make"]).mean(numeric_only=True)

MikeRatcliffe commented 1 year ago

I can confirm this.

Also, in the Describing Data with Pandas section:

  1. You need to use car_sales.mean(numeric_only=True) as numeric_only defaults to False.
  2. car_sales["Price"] = car_sales["Price"].str.replace('[\$\,\.]', '').astype(int) now throws Invalid escape sequence '\$. You need to use car_sales["Price"] = car_sales["Price"].str.replace('[$,]', '', regex=True).astype('float') instead.
vonstegen commented 10 months ago

I just wanted to add to this as well because I had similar problems starting in Section 6 - Lesson 53 and Lesson 55 with using car_sales.mean() and car_sales.groupby(["Make"]).mean().

I just wanted to post the panda link to why this "TypeError" occurs for those who come across this problem.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.mean.html

rezanaquib commented 8 months ago

Hi everyone, I have tried this code, but it didn't work in my jupyter. Anyone know why and how to solve this?

This is my code: df = pd.read_csv("heart-disease.csv")

And this is the error explaination: AttributeError Traceback (most recent call last) Cell In[10], line 1 ----> 1 df = pd.read_csv("heart-disease.csv")

AttributeError: module 'pandas' has no attribute 'read_csv'

kRiShNa-429407 commented 8 months ago

Re import pandas correctly And check have you made any mistakes