0

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. enter image description here

1 Answers1

1

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.