简体   繁体   中英

Pandas: Python dataframe plot a graph for values within a range

I am building an application for databases, and i am at part where i want my program to display a graph of column A vs Column B but for limited range of data in column B.

I want to display a graph for violation code vs number whilst the number is between 10 and 100. With my code below i am able to plot a graph for data that is < 100, but i also want to add >10 and my syntax keeps getting errors as i am unsure how i can do this.

GroupB = df[df['Number of Facilities'] < 100]
GroupB.plot(kind="bar", fontsize=4, x='VIOLATION CODE',
                      y='Number of Facilities',)
GroupB = df[(df['Number of Facilities'] < 100) & (df['Number of Facilities'] > 10)]

Parentheses are not optionals if you want to make an "and" operation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM