密谋:如何将条形图键视为类别而不是连续数字?

时间:2018-08-06 07:06:28

标签: pandas plotly

我在Plotly中有以下条形图代码:

Create table #t ( id int identity (1,1), Empid int , Month varchar
(10), Salary int, Paymentdate date )


insert into #t (Empid ,Month,Salary,Paymentdate) Select
'1','Jan',1000, '2018-01-01'

insert into #t (Empid ,Month,Salary,Paymentdate) Select
'1','Feb',1500, '2018-02-01'

Select * from #t

SELECT TOP 1
    Empid, SALARY AS CUR_SAL, Lead(SALARY, 1, 0) OVER (ORDER BY PaymentDate DESC) AS PREV_SAL FROM
    #t ORDER BY
    Paymentdate DESC




SELECT TOP 1
    Empid, SALARY AS CUR_SAL, LAG(SALARY, 1, 0) OVER (ORDER BY PaymentDate DESC) AS PREV_SAL FROM
    #t ORDER BY
    Paymentdate DESC

问题是“ id”的范围可以从0到10000,但是中间的许多数字被省略了。因此,我在Plotly中的大多数条形图看上去都是空的。

如何将df = df.groupby("id").id.count() data = [go.Bar( x=df.keys(), y=df )] py.iplot(data) 视为不同类别的名称,而不是连续的数字范围?

谢谢。

0 个答案:

没有答案