EXERCISE: Are two separate linear regression models, one for smokers and one of non-smokers, better than a single linear regression model?

I tried creating a separate models for smokers and non smokers by repeating the steps given. I thought by using only the non_smoker_df i could repeat the same steps by changing the sex columns to 0 and 1 and also one hot encode the region column. Since non_smoker_df was already made i tried making that ‘no’ into 0 and i get this error. Is the error because the non_smoker_df is not actually a data frame ?

non_smoker_df

smoker_value={‘no’:0}

non_smoker_df[smoker_value] = non_smoker_df.smoker.map(smoker_value)

non_smoker_df.charges.corr(non_smoker_df.smoker_value)


TypeError Traceback (most recent call last)
in ()
1 smoker_value={‘no’:0}
----> 2 non_smoker_df[smoker_value] = non_smoker_df.smoker.map(smoker_value)
3 non_smoker_df.charges.corr(non_smoker_df.smoker_value)

3 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/indexes/base.py in contains(self, key)
4072 False
4073 “”"
→ 4074 hash(key)
4075 try:
4076 return key in self._engine

TypeError: unhashable type: ‘dict’