histgram by group and use seaborn
import pandas as pd
url = 'https://raw.githubusercontent.com/subhadipml/California-Housing-Price-Prediction/master/housing.csv'
df = pd.read_csv(url)
df
x1 = df[df['ocean_proximity'] == "NEAR BAY"]
x2 = df[df['ocean_proximity'] == "<1H OCEAN"]
#Make a histogram of x1 with nice titles, axes labels and colored blue.
import seaborn as sns
import matplotlib.pyplot as plt
kwargs = dict(hist_kws={'alpha':.6},kde_kws={'linewidth':2})
plt.figure(figsize=(10,7),dpi=80)
sns.distplot(x1, color='blue',label='NEAR_BAY',**kwargs)
I get this error:
ValueError Traceback (most recent call last)
<ipython-input-65-4b17a157e7b5> in <module>()
1 #make the histogram
----> 2 sns.distplot(x1, color='blue',label='NEAR_BAY',**kwargs)
3 frames
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py in asarray(a, dtype, order)
81
82 """
---> 83 return array(a, dtype, copy=False, order=order)
84
85
ValueError: could not convert string to float: 'NEAR BAY'
Anyone can help?
from Recent Questions - Stack Overflow https://ift.tt/36osnRt
https://ift.tt/eA8V8J
Comments
Post a Comment