You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.4 KiB
62 lines
1.4 KiB
# -*- coding: utf-8 -*-
|
|
"""
|
|
utils.List2String
|
|
~~~~~~~~~~~~~~
|
|
|
|
List to String.
|
|
|
|
:copyright: 云南新八达科技有限公司.
|
|
:author: 李进才.
|
|
"""
|
|
|
|
|
|
def list2String(listString):
|
|
"""Constructor"""
|
|
content = ''
|
|
for key in listString:
|
|
content += key
|
|
return content
|
|
|
|
|
|
def list_intersection(listA, listB):
|
|
"""
|
|
两个集合找出相同的数据 交集
|
|
"""
|
|
return list(set(listA).intersection(set(listB)))
|
|
|
|
|
|
def list_union(listA, listB):
|
|
"""
|
|
两集合合并 并集
|
|
"""
|
|
return list(set(listA).union(set(listB)))
|
|
|
|
|
|
def list_difference(listA, listB):
|
|
"""
|
|
差集 在B不在A
|
|
"""
|
|
return list(set(listB).difference(set(listA)))
|
|
|
|
|
|
def list_paginate(pointList, pageNumber, page):
|
|
"""
|
|
list分页
|
|
@pointList list
|
|
@pageNumber 每一页的数据量
|
|
@page 页码
|
|
"""
|
|
if len(pointList) == 0:
|
|
return pointList
|
|
return [pointList[i:i + pageNumber] for i in range(0, len(pointList), pageNumber)][int(page)-1]
|
|
|
|
|
|
def dataFrame_paginate(df, page, offset, limit):
|
|
"""
|
|
dataFrame数据分页
|
|
@df dataFrame数据
|
|
@page 页码
|
|
@offset 偏移量 默认情况下,offset = limit 比如要取第5页前10条数据
|
|
@limit 每页数据量
|
|
"""
|
|
return df[(int(page) - 1) * int(offset): (int(page) - 1) * int(offset) + int(limit)]
|
|
|