I'd like to show the total number of orders per month in the sales raw data. Is it possible to calculate the y value as the conditional sum within the matplotlib package? Perhaps because the order number is the key value, the maximum value of the Y axis is 1 in the table ㅜ ( (I attached the image)
-- Revise the question after looking at the comments on September 23!
RAW DATA : Order quantity data recorded in time units
(Time in years, months, days, minutes, and seconds, and the number of orders at that time are recorded)
What I want to express on the graph: Total monthly order quantity (January to June)
Current problem: Graph is drawn with one order quantity, not total monthly order quantity
[Writing code] sns.barplot(data=raw, x="Month", y="Oder_Quantity", ax=ax1)
python
Suppose raw is a data frame where "order time" is a datetime type index.
In that case, you can draw the sum of monthly orders as follows:
group_sum = raw.resample('m')['order quantity'].sum()
group_sum.plot(kind='bar')
plt.show()
If "order time" is a string column other than a datetime type index,
raw["order time"] = pd.to_datetime(raw["order time"]) #Change the type of order time column to datetime.
The raw.set_index ("order time", inplace=True) #ordertime column is set to the index.
This may need to be preceded.
© 2024 OneMinuteCode. All rights reserved.