How to add a filter/query/condition in Plotly

I want to add a condition to the column where attractionName.value_counts() =165. How can I add a query/filter/condition to a DataFrame before I plot the data.

fig = px.bar(rwgor, x=attractionName, y=attraction score summary, color=attraction score summary, title=Long-Form Input)
fig.show()

With the above code I can plot all values in the column attractionName. I only want to plot values whose value_counts() is grater than 165.

Topic plotly matplotlib plotting pandas python

Category Data Science


Assuming your DataFrame is rwgor, you need to filter it like this:

rwgor = rwgor.loc[rwgor.attractionName >=165]
fig = px.bar(rwgor, x="attractionName", y="attraction score summary", color="attraction score summary", title="Long-Form Input")
fig.show()

or

fig = px.bar(rwgor.loc[rwgor.attractionName >=165], x="attractionName", y="attraction score summary", color="attraction score summary", title="Long-Form Input")
fig.show()

Finally, note that I used rwgor.attractionName >=165 and not rwgor.attractionName.value_counts() >=165, according your plot description.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.