我正在尝试对在 kaggle 上找到的商店交易数据集进行一些 EDA,准确地说是 https://www.kaggle.com/allunia/e-commerce-sales-forecast。
与所有优质商店一样,它为批量订单提供折扣。我想看看产品、数量和价格之间的关系。具体来说,我想知道如何将折扣阈值应用于数据集中的所有产品。
(同样值得注意的是,一个产品可能有多个阈值,即10件以下的价格、10-19件的价格和20件以上的价格。)
以下是数据示例和我的绘图尝试:
data = [['10', '20', '30',
'20', '20', '40',
'30', '20', '10', '40'],
[2.95, 9.95, 4.95,
5.55, 5.55, 8.5,
3.95, 3.95, 1.55, 7.95],
[5,8,3,
18,11,6,
11, 20, 20, 9]]
rows = zip(data[0], data[1], data[2])
headers = ['StockCode', 'UnitPrice', 'Quantity']
df = pd.DataFrame(rows, columns=headers)
pivot_df = df.pivot(index='StockCode', columns='Quantity', values='UnitPrice')
pivot_df.loc[:,list(df['Quantity'])].plot.bar(stacked=True, figsize=(10,7))
[输出]:
这不是我所追求的,我认为单价(y 轴)与 stockCode(x 轴)与数量的关系,因为层会显示我想要的关系。
因此我的问题是如何得到这个图?
作为次要问题,是否有更好的方法来可视化 产品、数量和价格的关系。
感谢您的时间。