如何找到每个城市的平均销售额?

时间:2020-12-21 14:19:11

标签: python pandas numpy

假设我们有一个这样的数据集:

 id        sales    city
 12        10000    New york
 13        15000    New york
 14        20000    Tokyo
 15        25000    Tokyo
 16        10000    Istanbul
 17        12000    Istanbul

如何找到每个城市的平均销售额?

使用这个,我想创建一个水平条形图。

1 个答案:

答案 0 :(得分:1)

var chart = new Chart(ctx, {
  type: "line",
  data: {
    labels: This.xAxis,
    datasets: [{
      backgroundColor: gradient,
      pointBackgroundColor: "white",
      borderWidth: 1,
      borderColor: "#5946B0",
      pointRadius: 2,
      displayColors: false,
      data: This.yAxis
    }]
  },
  options: {
    title: {
      display: false,
      text: "Test"
    },
    tooltips: {
      backgroundColor: "#FAFAFA",
      borderColor: "lightgreen",
      borderWidth: 1,
      titleFontColor: "black",
      titleFontStyle: "normal",
      displayColors: false,
      bodyFontColor: "black"
    },
    legend: {
      display: false
    },
    plugins: {
      zoom: {
        pan: {
          enabled: true,
          mode: "x",
          speed: 10,
          threshold: 10
        },
        zoom: {
          enabled: true,
          mode: "y"
        }
      }
    }
  }
});