jinja & pyechart联合构建html报告

2024-06-05 | html,plot

jinja&pyechart联合构建html报告

pyechart是一个具有良好交互性和精巧图表设计的开源的数据可视化python包;Jinja 是一款快速、富有表现力且可扩展的模板引擎,模板中的特殊占位符允许编写类似于 Python 语法的代码。二者结合,能便捷有效的生成数据分析报告。

阅读更多

python迭代器

2024-06-03 | python

python迭代器

基础概念

  • 可迭代对象(iterable):直接作用于for循环的对象;可使用iter()转换成迭代器。
  • 迭代器(iterator):使用next()函数调用并不断返回下一个值的对象

迭代器

无穷迭代器

无穷迭代器:count()、cycle()、repeat()

count

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

import itertools
i = 0
for base in itertools.count(start=10, step=2):
if i > 5:
break
print(base)
i += 1

# 10
# 12
# 14
# 16
# 18
# 20

cycle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

import itertools
i = 0
for base in itertools.cycle('ATCG'):
if i > 10:
break
print(base)
i += 1

# A
# T
# C
# G
# A
# T
# C
# G
# A
# T
# C

repeat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

import itertools
for base in itertools.repeat('abc', 3):
print(base)

# abc
# abc
# abc

for base in itertools.repeat(['a','b','c'], 3):
print(base)

# ['a', 'b', 'c']
# ['a', 'b', 'c']
# ['a', 'b', 'c']

有限迭代器

有限迭代器:accumulate()、chain()

accumulate

1
2
3
4
5
6
7
8
9
10
11
12
13

import itertools
for base in itertools.accumulate([1, 2, 3, 4, 5]):
print(base)

# 1
# 3
# 6
# 10
# 15



参考

reference:https://docs.python.org/zh-cn/3/library/itertools.html

阅读更多

pyCirclize

2024-06-02 | packages

reference

install

pip

1
2
3

pip install pycirclize

阅读更多

回归模型评价

2024-05-30 | Model

回归模型评价

回归模型的评价指标:MSE、RMSE、RMSLE、R2

阅读更多

python并行

2024-05-28 | python

Pparallelism

python并行执行任务

阅读更多

python循环优化

2024-05-28 | python

python循环优化

python中经常使用到for循环,需要消耗大量时间,本文将介绍一些简单的方法进行提速。

阅读更多