Home > Back-end >  Plot graph for only one specific value in a column
Plot graph for only one specific value in a column

Time:03-03

I am working with a dataset that looks at groceries, and the types of groceries, delivered at certain times of the day.

Dataset

I want to make a line graph of how much alcohol is delivered at certain hours of the day(order_hour_of_day, 0-23) as the y-axis, and the num_orders_hour as the x-axis. I know how to plot a graph between these columns but I am confused on how to only get the alcohol-related values

CodePudding user response:

You can do something like this (really simplified):

import pandas as pd 
import matplotlib.pyplot as plt

df2 = df.loc[(df['department']=='alcohol') & (df['order_hour_of_day'] >= 0) & (df['order_hour_of_day'] <= 23), :]

plt.plot(df2['num_orders_hour'], df2['order_hour_of_day'])
  • Related