美文网首页
添加顺序

添加顺序

作者: 大诗兄_zl | 来源:发表于2017-10-25 16:43 被阅读4次

    #add_derek

    iforderby !=Noneandorderby !='':

    orderlist=orderby.split(' ')

    aa=df.groupby(self.groupby).sum().sort_values(by=orderlist[0])

    row=aa[metrics[0]].copy()

    else:

    row = df.groupby(self.groupby).sum()[self.metrics[0]].copy()

    #add_end

    #row = df.groupby(self.groupby).sum()[self.metrics[0]].copy()

    #row.sort(ascending=False)

    columns = fd.get('columns')or[]

    print(columns)

    print('r3r3r3r3r3r3r3r3')

    解析:

    loc 在index的标签上进行索引,范围包括start和end.

    iloc 在index的位置上进行索引,不包括end.

    ix 先在index的标签上索引,索引不到就在index的位置上索引(如果index非全整数),不包括end.、

    s1=pd.Series(np.array([u'实拨资金支出业务',u'实拨资金支出业务',u'实拨资金支出业务',u'授权支付业务',u'授权支付业务',u'授权支付业务',u'直接支付业务',u'直接支付业务',u'直接支付业务','调拨支出业务'])

    s2=pd.Series(np.array([u'2017年04月',u'2017年05月',u'2017年06月',u'2017年04月',u'2017年05月',u'2017年06月',u'2017年04月',u'2017年05月',u'2017年06月',u'2017年06月']))

    s3=pd.Series(np.array([8.825884e+05,9.620184e+05,1.352481e+06,4.800228e+05,5.184789e+05,2.972734e+05,1.666538e+05,4.760356e+05, 4.074212e+05,6.212690e+05]))

    df=pd.DataFrame({u"FLAG":s1,u"月份":s2,u"当期发生额(万元)":s3});

    固定排序 

    >>> df['月份']=df['月份'].astype('category')

    >>> df['月份'].cat.set_categories(x_list,inplace=True)

    >>> df.sort_values('月份',ascending=True)

    相关文章

      网友评论

          本文标题:添加顺序

          本文链接:https://www.haomeiwen.com/subject/ypaqpxtx.html