[Need Help] How to create a histogram for certain conditional statements

I have been working on a case study project using Airbnb (Amsterdam) dataset in which I have to answer a business question which is “Plot a histogram of overall_satisfaction where the price is greater than equal to 100 and less than equal to 200” where overall_satisfaction and price are the features of the dataset. I have tried to filter the data first and store that into a variable and pass that variable to hist function as x value which gives me an error. So I’m stuck how can I solve this issue I tried almost everything on stackover flow and it stills gives an error. I’m using matplotlib to visualize it. so any help how can I visualize it using matlpoltlib.

Can you send the screenshot

@ak_alam, say your dataframe is data

Then you can plot the required histogram with :

plt.hist(data[data["overall_satisfaction"] >= 100 &  data["overall_satisfaction"] <= 200 ] )

You could also use

plt.hist(data.query("overall_satisfaction >= 100 & overall_satisfaction <= 200"))


plt.hist(data['overall_satisfaction'].between(100,200, inclusive=True))
© Copyright 2013-2019 Analytics Vidhya