我正在使用一個資料集,該資料集查看在一天中的特定時間交付的雜貨和雜貨型別。
資料集
我想制作一個折線圖,將一天中的某些時間(order_hour_of_day,0-23)作為 y 軸,將 num_orders_hour 作為 x 軸。我知道如何在這些列之間繪制圖表,但我對如何僅獲取與酒精相關的值感到困惑
uj5u.com熱心網友回復:
你可以做這樣的事情(真的很簡化):
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'])
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/438523.html
標籤:Python 熊猫 matplotlib
