0

I created some data

my_array = np.random.uniform(low=0 , high = 15,size = (1000))
my_list = ['car','boat','place','ship','train']
my_categorical = np.random.choice(a=my_list,size =(1000))
df = pd.DataFrame(np.column_stack((my_array.T,my_categorical.T)),columns=['numbers','cat'])re

Then i runned this code:

sns.set_theme(style='whitegrid')
sns.distplot(x = df['numbers'],kde=False)
plt.show()

This worked, but it said that it was going to be deprecated. So i tried to use one of the new options, displot.

sns.displot(data= df, x='numbers')

And didn't work. I'll copy the outputs.

enter image description here enter image description here

Tried to get an output as the one with displot

  • 1
    https://stackoverflow.com/questions/67638590/emulating-deprecated-seaborn-distplots – Mr. T Apr 05 '22 at 08:12
  • 1
    Already solved. The problem is that the column in the dataframe was in type object. – Daniel B Apr 05 '22 at 09:05
  • 1
    It's much easier to create the dataframe via a dictionary instead of grouping arrays, especially when the types are different. `df = pd.DataFrame({'numbers':my_array, 'cat':my_categorical})` – JohanC Apr 05 '22 at 12:39

0 Answers0