Reputation: 27
I am learning Data Science and I am trying to figure out why I see this difference. What I get:
import seaborn as sns
import matplotlib.pyplot as plt
from pandas.api.types import CategoricalDtype
diamonds = sns.load_dataset('diamonds')
df= diamonds.copy()
cut_categoriler= ["fair","good","very good","premium","ideal"]
df.cut= df.cut.astype(CategoricalDtype(categories = cut_categoriler, ordered= True))
df.head().T
sns.catplot(x= "cut" ,y= "price",data =df);
plt.show()
what I want:
Upvotes: 0
Views: 228
Reputation: 459
Don't do the cut operation that you are doing. The plot is pretty straightforward.
import seaborn as sns
import matplotlib.pyplot as plt
from pandas.api.types import CategoricalDtype
diamonds = sns.load_dataset('diamonds')
df= diamonds.copy()
df.head()
sns.catplot(x= "cut" ,y= "price",data = df);
plt.show()
Upvotes: 1